700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android自定义checkbox样式 Android 自定义CheckBox样式无效

android自定义checkbox样式 Android 自定义CheckBox样式无效

时间:2020-05-13 16:32:01

相关推荐

android自定义checkbox样式 Android 自定义CheckBox样式无效

先说结论,按网上的方式设置checkBox的button属性、background属性全部都失败了,然后发现在API19的模拟器上无法正常显示,在API26的真机上style样式正常显示,接着找低版本样式问题,然后发现了buttonCompat,设置一波,有效,链接如下。

/qq_36487432/article/details/104926509

1..写对应的selector文件

selector_checkbox.xml

2.xml配置

android:id="@+id/checkbox"

android:layout_width="@dimen/y10"

android:layout_height="@dimen/y10"

app:buttonCompat = "@null"

android:button="@drawable/selector_checkbox"

android:background="@null"/>

====================可优化成如下模式====================

android:id="@+id/checkbox"

style="@style/CustomCheckBox"/>

@dimen/y10

@dimen/y10

@null

@null

@drawable/selector_tining_delete_checkbox

3.效果图,去掉buttonCompat 属性后显示默认方框样式

image.png

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。