我有 android checkBox 并且默认背景是透明的,我希望它是白色的所以我使用样式:
<style name="BrandedCheckBox" parent="AppTheme">
<item name="colorAccent">@color/cyan</item>
<item name="colorControlNormal">@color/text_gray</item>
<item name="colorControlActivated">@color/cyan</item>
</style>
并设置复选框主题:
<CheckBox
android:id="@+id/check_payable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_gravity="center"
android:theme="@style/BrandedCheckBox"/>
谁能帮我解决这个问题?
最佳答案
你可以使用android:button
<CheckBox
android:id="@+id/check_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/checkbox_background" />
checkbox_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:drawable="@drawable/checkbox_checked" />
<item android:state_checked="false"
android:drawable="@drawable/checkbox_unchecked" />
</selector>
我在 drawable 中使用了这两张图片
关于android - 如何更改Android复选框的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41930297/