第一种:在原生中只调整显示位置等:

<CheckBox
android:id="@+id/checkBox8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null" //这个很重要,必须null
android:drawableBottom="?android:attr/listChoiceIndicatorMultiple" //显示格式以及位置
android:gravity="center_vertical"
android:layout_marginBottom="10dp"
android:layout_centerVertical="true"
android:text="测试按钮" />

效果:


第二种:直接自定义按钮类型
1、准备两个按钮的图片,表示选中和未选中状态,上传到drawable中,再加入一个格式定义
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/checkbox_select"
android:state_checked="true"/>
<item
android:drawable="@drawable/checkbox_noselect"
android:state_checked="false"/>
<item
android:drawable="@drawable/checkbox_noselect"/>

</selector>



2、再再style中定义对应的格式名称
<style name="checkboxstyle" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_selected</item>
</style>

3、再应用
<CheckBox
android:id="@+id/checkBox8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginBottom="10dp"
android:layout_centerVertical="true"
style="@style/checkboxstyle"
android:text="测试按钮" />

 
 

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

 

 
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄