先看下点赞的效果图
首先添加依赖
api 'com.sackcentury:shinebutton:0.2.0'
xml布局
看下属性说明:
属性
Java方法
描述
siShape
void setShapeResource(int)
设置原始资源(png)
btn_color
void setBtnColor(int)
设置原点颜色
btn_fill_color
void setBtnFillColor(int)
单击后设置填充颜色
allow_random_color
void setAllowRandomColor(boolean)
允许光泽颜色随机
shine_animation_duration
void setAnimDuration(int)
设置光泽动画持续时间
big_shine_color
void setBigShineColor (int)
设置大光泽的颜色
click_animation_duration
void setClickAnimDuration(int)
设置单击动画持续时间
enable_flashing
void enabaleFlashing (boolean)
启用闪光效果
shine_count
void setShineCount (int)
按钮周围设置闪耀计数
shine_distance_multiple
void setShineDistanceMultiple (float)
设置距离按钮的多个距离
shine_turn_angle
void setShineTurnAngle(float)
设置光泽的转角
shine_size
void setShineSize (int)
按像素设置光泽大小
small_shine_color
void setSmallShineColor(int)
设置小亮泽颜色
small_shine_offset_angle
void setSmallShineOffAngle(float)
将小光泽的角度偏移设置为大光泽
初始化控件:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ShineButton btLike = (ShineButton) findViewById(R.id.bt_like);
btLike.init(this);
ShineButton btSmile = (ShineButton) findViewById(R.id.bt_smile);
btSmile.init(this);
ShineButton btHeart = (ShineButton) findViewById(R.id.bt_heart);
btHeart.init(this);
ShineButton btStart = (ShineButton) findViewById(R.id.bt_star);
btStart.init(this);
}
}
github链接:
https://github.com/ChadCSong/ShineButton
另外github上一些优秀的开源项目,纯干货分享链接:
https://blog.csdn.net/yun382657988/article/details/83303147