从4.2开始,checkbox和右侧文字间距和之前版本有点差别,解决办法:
<CheckBox
android:id="@+id/register_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:background="@android:color/transparent"
android:drawableLeft="@drawable/checkbox_selector"
android:drawablePadding="5dp"
android:checked="true"
android:text="同意协议"
android:textColor="#669966"
android:textSize="14sp" />
自定义的CheckBox,checkbox_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checkbox_press" android:state_checked="true"></item>
<item android:drawable="@drawable/checkbox" android:state_checked="false"></item>
<item android:drawable="@drawable/checkbox" ></item>
</selector>
本文介绍了一个关于4.2版本中Checkbox与右侧文字间距出现的问题及解决方案。通过自定义CheckBox样式,调整了checkbox_selector.xml文件中的间距,解决了与之前版本间距不同的问题。
836

被折叠的 条评论
为什么被折叠?



