自定义CheckBox和RadioButton的样式
2016-04-23 22:02
501 查看
在drawable文件下新建一个selector_checkbox.xml
在values文件下新建一个custom_style.xml
在布局文件中引入自定义样式
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/check_normal" android:state_checked="false" /> <item android:drawable="@drawable/check_checked" android:state_checked="true" /> </selector>
在values文件下新建一个custom_style.xml
<resources> <!--自定义checkbox样式--> <style name="custom_checkbox_style"> <item name="android:button">@drawable/selector_check</item> </style> <!--自定义radiobutton样式--> <style name="custom_radiobutton_style"> <item name="android:button">@drawable/selector_check</item> </style> </resources>
在布局文件中引入自定义样式
<CheckBox android:id="@+id/checkbox" style="@style/custom_checkbox_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/checkbox" /> <RadioButton android:id="@+id/radio_button" style="@style/custom_radiobutton_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/radiobutton" />
相关文章推荐
- Less:优雅的写CSS代码
- css 射线实现方法
- CSS流布局权威指南
- 第四章 CSS盒子模型
- HTML CSS
- CSS3梅花三弄特效
- Html和CSS的一些自我感悟(亲测,持续更新中...)
- CSS选择器
- css3折叠效果
- 《CSS3实战》笔记--色彩模式和不透明度
- CSS实现垂直居中的5种方法
- css 常用代码片段
- CSS---左右固定,中间自适应布局
- CSS3实现2D变换
- WEB前端--CSS样式优先级
- CSS3颜色渐变模式总结
- 导航菜单的样式
- CSS3新特性,让文本在父布局垂直居中显示
- Only女装首页HTML+CSS代码实现
- 《CSS3实战》笔记--溢出文本省略:text-overflow和文本换行显示:word-wrop