Android studio 自定义多选框CheckBox
16lz
2021-01-23
注意
1.选择框图片9.png格式无效,无法自动根据字体改变大小
2.自定义button控件是改变
android:background="@drawable/button_skin"
自定义多选框是改变
style="@style/CustomCheckboxTheme"
以下3步只需要修改高亮部分
1.首先在drawable文件夹中添加drawable文件checkbox_style.xml。
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/check_normal_9" android:state_checked="false" /> <item android:drawable="@drawable/check_select_9" android:state_checked="true" />selector>
2.在values文件夹下的styles.xml文件中添加CustomCheckboxTheme样式。 [html] view plain copy
- <style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
- <item name="android:button">@drawable/checkbox_styleitem>
- style>
[html] view plain copy
- <CheckBox
- android:id="@+id/cb_all"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/CustomCheckboxTheme" />
效果如下(图片资源可以自定义)
更多相关文章
- Android 导入android源码有错,R.java文件不能自动生成解决方法
- 自定义SeekBar样式
- Android dex ,xml 文件反编译方法
- android/java 计算大文件的sha1值
- 【Android 设计】:样式_ 图解
- Android开发的文件格式概述