Material Design动画其一:触摸反馈
2016-11-26 本文已影响664人
森与渊
【涟漪效果】
系统效果:设定background为
?android:attr/selectableItemBackgroundBorderless·无边界,即圆形的涟漪效果
?android:attr/selectableItemBackground·有边界的涟漪效果
自定义颜色:在style文件中修改属性
![](https://img.haomeiwen.com/i804467/c0cdaa79157e77b4.png)
自定义RippleDrawable:该类作为background会有涟漪效果,
构造函数:RippleDrawable(ColorStateList color,Drawable content,Drawable mask)
color,是设定涟漪颜色,content是设定静态背景,mask是自定义涟漪的形状
xml文件如图
![](https://img.haomeiwen.com/i804467/07e1cce3c49ce5fa.png)
【浮动响应】详情见状态改变动画
自定义的动画selector:
![](https://img.haomeiwen.com/i804467/2bbecca07ac87513.png)
设置到属性android:stateListAnimator中
![](https://img.haomeiwen.com/i804467/d89346931544db2b.png)