Android中Selsetor基本使用三,选中时改变CheckBox背景
2016-06-17 14:22
477 查看
效果图
未选中
选中
activity_main.xml文件中
checkbox_style.xml
源码下载:
http://download.csdn.net/detail/zhaihaohao1/9552539
未选中
选中
activity_main.xml文件中
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.zhh.demo.MainActivity"> <CheckBox android:id="@+id/cb" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_width="match_parent" android:layout_height="50dp" android:text="测试背景的改变" android:paddingLeft="10dp" android:textSize="18sp" android:button="@drawable/checkbox_style" /> </LinearLayout></span>背景选择器,选中,未选中换两张图片就好了
checkbox_style.xml
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@mipmap/chex_on" android:state_checked="true"/> <item android:drawable="@mipmap/chex_nm" android:state_checked="false"/> <item android:drawable="@mipmap/chex_nm"/> </selector></span>
源码下载:
http://download.csdn.net/detail/zhaihaohao1/9552539
相关文章推荐
- Android 实现模糊半透明效果的简单实现
- Android 短信的备份
- Android学习笔记六之Service二
- Fragment 重叠(重影)问题
- AndroidGUI27中findViewById返回null的快速解决办法
- android listview系列之初步接触listview(二)
- Android传感器(三):方向传感器
- android沉浸式状态栏
- 两台Android机子Adb连接
- Android中findViewById返回为空null的快速解决办法
- Android AsyncTask完全解析,带你从源码的角度彻底理解
- Android内存优化总结【整理】
- Android学习之Handler使用小结
- [Android官方Demo系列] PageTransformer翻转动画
- android中跨进程通讯的4种方式
- 学习Android三个月后的疑惑
- Android中SurfaceView的使用详解
- RecycleView
- 彻底明白Android中AIDL及其使用
- Android——第三方登录——新浪微博——获取用户信息——账户绑定