Android给控件添加默认点击效果
16lz
2021-12-04
Android控件点击效果
Android中Button控件是有点击效果的,但是像TextView、ImageView、各种Layout是没有点击效果的,给TextView设置点击事件后,加个点击效果用户触控反馈会好一点;
最简单的默认点击效果:
android:background="?android:attr/selectableItemBackground"
如果该空间已经有背景色了,可以设置前景色
android:foreground="?android:attr/selectableItemBackground"
这样一个Android原生的涟漪效果就出来了;
注意:
?android:attr/selectableItemBackgroundBorderless ?android:attr/selectableItemBackground
前景色:foreground属性只能给控件和帧布局设置,其它的布局设置无效果,具体看Android源码;
也可自定义,按照你的需求来:
<?xml version="1.0" encoding="utf-8"?>
转载于:https://www.cnblogs.com/cuichen16/p/10785926.html
更多相关文章
- Android—Service详解—模拟点击抽奖(2020.7.3)
- android:configChanges 问题
- 【Android】TextView 属性详解
- ionic3中android状态栏
- [置顶] EditText属性大全
- 【Android(安卓)界面效果42】如何自定义字体
- android listview 自定义分割线总结
- EditText禁止输入中文设置
- Android(安卓)Styles and Themes