android 中checkbox radiobutton文字间间距处理
2013-10-23 22:28
525 查看
情况:ui设计要求必须让checkbox或者radiobutton和textview有一定的间距
处理:
1,使用空间的style属性来给checkboxbox和radiobutton附加样式
2,在drawable下增加styles.xml要用的图形资源和部分状态初始值。假设xml叫checkbox_login.xml 内容如下
[html] view
plaincopy
<?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定义
[html] view
plaincopy
<!-- 登陆页面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属性来调用吧
[html] view
plaincopy
<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 内容如下
[html] view
plaincopy
<?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定义
[html] view
plaincopy
<!-- 登陆页面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属性来调用吧
[html] view
plaincopy
<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中的button,且设置与文字的间距
- android CheckBox RadioButton 照片和文字的间距问题
- android CheckBox RadioButton 图片与文字间距问题
- android CheckBox和右侧文字间距问题
- android中checkbox文字和复选框的间距设置问题
- android 改变CheckBox和后面文字的间距
- Android-CheckBox和RadioButton调整间距(有坑,注意)
- android RadioButton 图片与文字间距问题
- Android视觉规范-间距规范与文字规范单位换算(dip、sp与px)
- Android checkbox和radiobutton 以及Toast和AlertDialog的使用
- checkbox与文字的间距
- Android基础控件 - RadioButton与CheckBox
- Android中如何设置RadioButton在文字的右边,图标在左边
- android RadioButton和CheckBox组件的使用方法
- android 自定义 radiobutton 文字颜色随选中状态而改变
- 关于如何处理checkbox的小方框与文字上下不匹配的问题
- Android控制文字水平间距android:letterSpacing
- Android RadioButton背景图片和文字的相对位置