android 中checkbox radiobutton文字间间距处理
2013-06-09 13:03
411 查看
情况:ui设计要求必须让checkbox或者radiobutton和textview有一定的间距
处理:
1,使用空间的style属性来给checkboxbox和radiobutton附加样式
2,在drawable下增加styles.xml要用的图形资源和部分状态初始值。假设xml叫checkbox_login.xml 内容如下
3,在values目录下增加styles.xml并定义style元素调用上面的xml定义
<!-- 登陆页面checkbox样式 -->
<style name="LoginCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_login</item>
<item name="android:paddingLeft">20dip</item>
</style>
4,接下来在layout的checkbox和radiobutton中通过style属性来调用吧
<CheckBox
android:id="@+id/autosavepassword"
style="@style/LoginCheckboxTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="85dip"
android:checked="false"
android:text="@string/auto_save_password"
android:textColor="#6A6A6A" />
结束!
处理:
1,使用空间的style属性来给checkboxbox和radiobutton附加样式
2,在drawable下增加styles.xml要用的图形资源和部分状态初始值。假设xml叫checkbox_login.xml 内容如下
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/checkboxed" android:state_checked="true" /> <item android:drawable="@drawable/uncheckbox" android:state_checked="false"/> <item android:drawable="@drawable/checkboxed"/> </selector>
3,在values目录下增加styles.xml并定义style元素调用上面的xml定义
<!-- 登陆页面checkbox样式 -->
<style name="LoginCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_login</item>
<item name="android:paddingLeft">20dip</item>
</style>
4,接下来在layout的checkbox和radiobutton中通过style属性来调用吧
<CheckBox
android:id="@+id/autosavepassword"
style="@style/LoginCheckboxTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="85dip"
android:checked="false"
android:text="@string/auto_save_password"
android:textColor="#6A6A6A" />
结束!
相关文章推荐
- android 中checkbox radiobutton文字间间距处理
- android CheckBox RadioButton 照片和文字的间距问题
- android CheckBox RadioButton 图片与文字间距问题
- android CheckBox RadioButton 图片与文字间距问题
- Android 自定义CheckBox RadioButton中的button,且设置与文字的间距
- android 改变CheckBox和后面文字的间距
- android RadioButton 图片与文字间距问题
- Android-CheckBox和RadioButton调整间距(有坑,注意)
- android CheckBox和右侧文字间距问题
- android中checkbox文字和复选框的间距设置问题
- 【按住你的心】——Android开发CheckBox&RadioButton控件的简单使用
- 转 Android RadioButton设置选中时文字和背景颜色同时改变
- android 自定义 radiobutton 文字颜色随选中状态而改变
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- Android视觉规范-间距规范与文字规范单位换算(dip、sp与px)
- Android控件之CheckBox、RadioGroup、RadioButton
- android 自定义 radiobutton 文字颜色随选中状态而改变
- Android 基础控件之CheckBox与RadioButton
- Android—RadioButton(单选框)和CheckBox(复选框)
- 自定义CheckBox的复选框、复选框和文字的间距