美文网首页
点赞特效

点赞特效

作者: Wocus | 来源:发表于2018-08-01 11:11 被阅读14次

GitHub原文地址:https://github.com/jd-alexander/LikeButton

使用步骤

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);

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

相关文章

网友评论

      本文标题:点赞特效

      本文链接:https://www.haomeiwen.com/subject/cmplvftx.html