Giter VIP home page Giter VIP logo

hotheart's Introduction

HotHeart

抖音APP点赞效果实现,模仿抖音APP双击屏幕蹦出心图,特点: 1. 可以自定义图片 2. 可以自定义旋转角度 3.可以自定义是否抖动一下再放大消失 4. 超级简洁,占用内存小

预览

预览图片

使用

第一步: 在项目根目录的build.gradle文件中加入

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

第二步: 添加依赖项

dependencies {
	implementation 'com.github.KevinYou128:HotHeart:v1.2.4'
}

第三步:直接在布局文件里调用

<com.yqw.hotheart.HeartFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:app="http://schemas.android.com/apk/res-auto"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	app:degrees_interval_max="20"
	app:degrees_interval_min="-20"
	app:swipe_image="@drawable/ic_heart"
	tools:context=".MainActivity">
<ImageView
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:src="@drawable/douyin" />
</com.yqw.hotheart.HeartFrameLayout>

直接在你的父布局外层包裹上hotheart布局就可以了,另外,考虑到缩减布局层数,我特意添加了HeartLinearLayout、HeartConstraintLayout、HeartRelativeLayout、HeartFrameLayout等父容器,你可以直接使用它们来替换你的原生布局,以达到缩减布局层数的效果。

XML属性说明

heart_swipe_image:点击时需要显示的图片

heart_shake:设置是否有抖动效果,默认为抖动,设置false为不抖动

heart_refresh_rate:设置动画刷新频率,默认为16,数值越大动画表现越慢,建议使用默认就好了

heart_degrees_interval_min:图片最小旋转角度,默认-30,取值范围为-360到360(注意取值小于或等于max)

heart_degrees_interval_max:图片最大旋转角度,默认30,取值范围为-360到360(注意取值大于或等于min)

java代码属性说明

setOnDoubleClickListener:双击事件监听

示例:

heart.setOnDoubleClickListener(new OnDoubleClickListener() {
        @Override
        public void onDoubleClick(View view) {
            //双击事件处理
        }
    });

点击事件:

    heart.setOnDoubleClickListener(new OnDoubleClickListener() {
        @Override
        public void onDoubleClick(View view) {
            showToast("双击了");

        }
    });
    heart.setOnSimpleClickListener(new OnSimpleClickListener() {
        @Override
        public void onSimpleClick(View view) {
            showToast("单击了");
        }
    });

setSwipeImage(int id):设置点击时需要显示的图片

setRefreshRate(int refreshRate):设置动画刷新频率,默认为16,数值越大动画表现越慢,建议使用默认就好了

setDegreesInterval(int min,int max):设置图片旋转角度区间,默认-30到30
min取值范围为-360到360
max取值范围为-360到360

博客地址

最后

欢迎交流意见!

hotheart's People

Contributors

kevinyou128 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.