android 5.0以上版本控件点击 水波纹效果
16lz
2021-12-04
android api21及以上引入了控件点击的水波纹效果
1.可以直接给控件设置
android:background="?android:attr/selectableItemBackground"(有边界效果)
或者 android:backgroundTint="?android:attr/selectableItemBackgroundBorderless”(无边界效果)
2、设置selector
drawable中创建selector文件,版本低于21时使用,例如:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <item android:drawable="@color/colorPrimaryDark" android:state_pressed="true" /> <item android:drawable="@color/colorPrimary" />selector>
res目录下创建文件夹 drawable-v21 ,并创建xml文件:
<?xml version="1.0" encoding="utf-8"?><ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/color_half_black"> <item>
< shape android :innerRadius= "5dp" android :shape= "rectangle"> < solid android :color= "@color/colorPrimary" /> < corners android :radius= "5dp" /> shape> item>
ripple> 是不是很简单。
更多相关文章
- android图片切换ImageSwichter的动画切换效果
- android图片切换ImageSwichter的动画切换效果
- [Android] TextView的垂直滚动效果
- android支付宝首页、蚂蚁森林效果、视频背景、校园电台、载入收
- Android(安卓)RelativeLayout中layout_marginBottom失效
- Android图片堆叠效果实现
- Android(安卓)TextView跑马灯效果
- android 走马灯效果
- android使用xml布局文件设计提示对话框