android 点击变色的两种情况、textview点击变色以及自定义checkbox
来源:互联网 发布:网络贷款能不能报案 编辑:程序博客网 时间:2024/05/29 10:08
注意,对于布局类型的,设置clickable=true
1.不需要使用shape的情况
drawable下新建一个资源文件,在需要的地方setbackground
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/del"/> <item android:state_pressed="false" android:drawable="@color/main_color"/></selector>
2.需要设置圆角等等需要自定义shape的,和1类似,只是里面的drawable="@color"换做@drawable
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false" android:drawable="@drawable/fillet_rectangle_5dp_bg"/> <item android:state_pressed="true" android:drawable="@drawable/login_shape_two"/></selector>3.textview的点击变色
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:color="@color/del"></item> <item android:color="@color/main_color"/></selector>不能和上面的一样设置,否则颜色会和设定的不一致,原因不详
3.自定义checkbox
设置checkbox @Android:button="@null",而后设置background
backgroud使用的xml文件如下:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/shi_tab" android:state_checked="true"></item> <item android:drawable="@drawable/fou_tab" android:state_checked="false"></item></selector>
0 0
- android 点击变色的两种情况、textview点击变色以及自定义checkbox
- 自定义圆角点击变色TextView
- 关于实现“点击记录变色”的情况
- Button,TextView点击字体变色
- TextView点击变色(selector)
- 动态添加Textview+点击变色
- Androidstudio之TextView点击变色
- android 自定义按钮,点击变色,圆角
- ListView的点击变色
- TextView自定义省略号、部分文字变色、部分文字点击
- 点击变色
- 点击变色
- 点击变色
- 点击变色
- android点击ListView的item后变色
- jquery实现点击步骤条变色,以及点击下一步变色
- textview 中间的字变色并可点击
- android GridView条目点击变色
- 拟牛顿法
- Flutter进阶—创建有状态控件
- Graphivz中文显示问题
- leetcode 442. Find All Duplicates in an Array
- 网络访问之HttpClient
- android 点击变色的两种情况、textview点击变色以及自定义checkbox
- Mac 写asp.net记录
- Ubuntu 14.04 MySQL Server安装
- java中http的post和get请求,请求结果json转为对象或Map型
- msgpack宏使用方法
- 5-9 旅游规划 (实用)
- Android中bitmap图片压缩方式
- Unity自定义类的序列化
- Java设计模式之单例模式