我有一个圆形的自定义复选框,在 KitKat 上按钮呈现得很好,但在 ICS 上它们在未被选中时变黑。我将按钮和可绘制对象的样式定义如下:
<style name="FilledCheckButton" parent="android:style/Widget.CompoundButton.CheckBox" >
<item name="android:background">@drawable/v4_btn_weekday</item>
<item name="android:button">@drawable/v4_btn_weekday</item>
<item name="android:gravity">center</item>
</style>
这是 v4_btn_weekday 可绘制对象:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:color="@android:color/white"
android:drawable="@drawable/filled_circle_green"
android:state_checked="true"
android:state_pressed="true" />
<item android:color="@android:color/white"
android:drawable="@drawable/filled_circle_green"
android:state_pressed="true" />
<item android:color="@android:color/white"
android:drawable="@drawable/filled_circle_green"
android:state_checked="true" />
<item android:color="@color/v4_btn_radio_text_flat"
android:drawable="@drawable/empty_circle_green" />
</selector>
这是 empty_circle_green 可绘制对象:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke android:color="#00a74f" android:width="2dp"/>
</shape>
我错过了什么吗?谢谢。
这些是效果图: - 在 KK 上,每个未选择的日子看起来都不错
- 在 ICS 上,未选择的日子会停电
最佳答案
您必须为 empty_circle_green 可绘制对象设置背景。只需添加具有透明颜色的实体即可。
关于android,在 KitKat 上工作时背景资源在 ICS 上变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26710145/