问题描述:
CheckBox的Button按钮,即选择框位于最左边,!checkbox
,目标样式为选择框居中,不含文字。
尝试android:padding、android:layout_margin、text=”@null”等各种设置均无效。
解决方案:
用选择器selector,准备两张图片(一张是选中状态时显示的样子,一张是未选中时的样子),点击时换图
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/图片1" android:state_checked="true"></item>
<item android:drawable="@drawable/图片2" android:state_checked="false"></item>
</selector>
CheckBox属性设置为
<CheckBox
android:id="@+id/checkbox"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:button="@null"
android:drawableStart="@drawable/selector"/>
没对齐的话再设置下pading啥的调整下就行了