Android(安卓)自定义的checkbox
16lz
2021-12-04
1 定义显示效果,在res/drawable文件下新建xml文件 如mycheckbox.xml
2 定义checkbox并在其中引用上面定义好的drawable
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><item android:state_window_focused="false" android:state_enabled="true" android:state_checked="true" android:drawable="@drawable/check1" /><item android:state_window_focused="false" android:state_enabled="true" android:state_checked="false" android:drawable="@drawable/check2" /><item android:state_enabled="true" android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/check1" /><item android:state_enabled="true" android:state_checked="false" android:state_pressed="true" android:drawable="@drawable/check2" /><item android:state_focused="true" android:state_enabled="true" android:state_checked="true" android:drawable="@drawable/check1" /><item android:state_focused="true" android:state_enabled="true" android:state_checked="false" android:drawable="@drawable/check2" /><item android:state_enabled="true" android:state_checked="false" android:drawable="@drawable/check2" /><item android:state_enabled="true" android:state_checked="true" android:drawable="@drawable/check1" /></selector>
2 定义checkbox并在其中引用上面定义好的drawable
<CheckBox android:id="@+id/Checked" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:button="@drawable/mycheckbox"/>
更多相关文章
- NPM 和webpack 的基础使用
- 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
- Android(安卓)自定义CheckBox 样式
- Android(安卓)命令行手动编译打包详解
- 2011.09.07(2)——— android 跨进程通信之隐式intent
- 2011.09.07(4)——— android 跨进程通信之content provider
- Ubuntu10.10下真机调试
- android 往sd卡中写入文件
- Android(安卓)建立文件夹、生成文件并写入文本文件内容