Android几种方式(style、selector)实现圆形的CheckBox,android checkbox圆形按钮样式,Android简单实现圆形CheckBox,Android CheckBox圆形复选框
这里不重写CheckBox,只是设置xml。
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_30"
style="@style/Widget.AppCompat.CompoundButton.RadioButton"/>
主要是style="@style/Widget.AppCompat.CompoundButton.RadioButton"这个配置
依赖selector实现
首先在drawable中创建xxxxxx.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/picture_icon_sel" android:state_checked="true"/>
<item android:drawable="@drawable/picture_icon_sel" android:state_selected="true"/>
<item android:drawable="@drawable/picture_icon_sel" android:state_pressed="true"/>
<item android:drawable="@drawable/picture_wechat_num_oval_normal_a"/>
selector>
创建CheckBox 设置 background=@drawable/xxxxxx
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/xxxxxx"/>
或者 设置button=@drawable/xxxxxx
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/xxxxxx"/>
1)、RadioButton样式:有点击效果,实现简单,选中状态不是对勾,可改颜色
2)、selector实现,background=@drawable/xxxxxx 没有点击效果,但是可以设置宽高和图片大小,图片居中,增加点击区域,增加点击灵敏度,代码如下:
<CheckBox
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleX="0.5"
android:scaleY="0.5"
android:background="@drawable/selector_login_argument"
android:button="@null" />
3)、selector实现,设置button=@drawable/xxxxxx 有点击效果,可设置宽高不能设置按钮大小,图片不居中,如果想要居中需要重写CheckBox
左RadioButton样式,右依赖selector实现

点击效果就不上图片了,还要做GIF, 我懒…