RecyclerView 实现item点击水波纹动画
2017-04-14 13:59
323 查看
第一种方法:
直接在Item View中的LinearLayout /or CardView 添加代码–》xml代码:
android:background="?android:attr/selectableItemBackground" android:clickable="true" android:focusable="true"1
2
3
[/code]
第二种方法:
在res/drawable 和 res/drawable-v21 中分别添加item_selector.xml –》res/ drawable/ item_selector.xml 代码:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/text_Grey" android:state_pressed="true"/> <item android:drawable="@color/text_Grey" android:state_focused="true"/> <item android:drawable="@color/colorWhite"/> </selector>1
2
3
4
5
6
[/code]
res/ drawable-v21/ item_selector.xml 代码:
<?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/text_Grey"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="1dp" /> <solid android:color="@color/colorWhite" /> </shape> </item> </ripple>1
2
3
4
5
6
7
8
9
10
[/code]
colors.xml 代码:
<color name="text_Grey">#8496a0</color> <color name="colorWhite">#ffffff</color>1
2
3
[/code]
然后在Item View中的LinearLayout /or CardView 添加代码–》
xml代码:
android:background="@drawable/item_selector" android:clickable="true" android:focusable="true"1
2
3
[/code]
Button 完美效果
res/ drawable-v21/ item_selector.xml 代码:<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/btn_white"/> <corners android:radius="4dp"/> </shape> </item> <item android:drawable="?android:selectableItemBackground"/> </layer-list>1
2
3
4
5
6
7
8
9
10
11
[/code]
相关文章推荐
- RecyclerView的Item点击事件,增加删除Item瀑布流动画效果,长按拖动Item,RecyclerView复杂布局、实现新闻频道选择器
- RecyclerView 添加头部和尾部,并实现Item的点击事件
- RecyclerView的Item点击事件实现总结
- 详解Android中回调机制与RecyclerView的Item点击事件实现
- 利用RecyclerView实现的一个动画给变item的位置和左右滑动删除该RcyclervView的Item条目
- RecyclerView 添加头部和尾部,并实现Item的点击事件
- RecyclerView加载不同item并实现其item点击事件,实现添加常用应用的功能
- RecycleView设置点击的两种方式:adapter中的onBindViewHolder(VH,int)方法中进行;实现RecyclerView的addonItemTouchListerner()
- RecyclerView介绍(五)----实现点击效果以及动画
- Android中RecyclerView的item运用覆盖view的方法实现item的动画效果
- 从源码角度入手实现RecyclerView的Item点击事件
- RecyclerView实现Item滑动加载进入动画效果
- RecyclerView实现上拉刷新,下拉加载,item点击事件
- RecyclerView抽取基类,item实现点击,增加分割线
- RecyclerView实现Item点击事件方法二
- 精通RecyclerView:打造ListView、GridView、瀑布流;学会添加分割线、 添加删除动画 、Item点击事件
- RecyclerView实现Item滑动加载进入动画效果
- RecyclerView实现Item点击事件方法三/四
- Android实现RecyclerView自动点击Item中的控件
- Android中RecyclerView的item实现动画的效果