您的当前位置:首页正文

点赞特效

来源:华拓网

使用步骤

1.添加依赖:

  compile 'com.github.jd-alexander:LikeButton:0.2.3'

2.布局文件加入

<com.like.LikeButton
            app:icon_type="heart"
            app:icon_size="25dp"
            android:id="@+id/star_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
设置是否已经点赞

xml

app:liked="true"

java

likeButton.setLiked(true);
监听事件
likeButton.setOnLikeListener(new OnLikeListener() {
            @Override
            public void liked(LikeButton likeButton) {

            }

            @Override
            public void unLiked(LikeButton likeButton) {

            }
        });
设计ICON大小

xml

app:icon_size="20dp"

java

likeButton.setIconSizePx(40);
likeButton.setIconSizeDp(20);
设置ICON

xml

app:like_drawable="@drawable/thumb_on"
app:unlike_drawable="@drawable/thumb_off"

java

likeButton.setLikeDrawable(heart_on);
likeButton.setUnlikeDrawable(heart_off);

除此之外,还可以改变动画颜色,颗粒大小