我无法自定义我的复选框,虽然我已经在 xml 首选项文件中定义了背景,但它不会拉取文件。1.我正在尝试为复选框显示自定义图像,并将选择器 xml 定义为“android_button.xml”,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checkable="true"
android:drawable="@drawable/state_normal" /> <!-- pressed -->
<item android:state_checked="true"
android:drawable="@drawable/android_pressed" /> <!-- focused -->
<item android:drawable="@drawable/state_normal" /> <!-- default -->
</selector>
state_normal 和 android_pressed 是 res>drawable 文件夹中的两个 .png 图像。
2.我的 Checkbox preference.xml 文件是:
<CheckBoxPreference android:key="@string/Drop_Option"
android:title="Close after call drop"
android:defaultValue="true"
android:background="@drawable/android_button"
/>
定义中是否有任何错误,屏幕中显示的唯一更改是 android:title 文本,如果我更改文本,它会更改文本。没有其他变化。我该如何解决。谢谢你的建议。