android,在 KitKat 上工作时背景资源在 ICS 上变黑

标签 android android-drawable

我有一个圆形的自定义复选框,在 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 上,每个未选择的日子看起来都不错

On KK

  • 在 ICS 上,未选择的日子会停电

On ICS

最佳答案

您必须为 empty_circle_green 可绘制对象设置背景。只需添加具有透明颜色的实体即可。

关于android,在 KitKat 上工作时背景资源在 ICS 上变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26710145/

相关文章:

android - 转换为html时如何将可绘制名称发送到服务器?

android - 如何在使用 native 短信编辑器发送短信后返回到 Intent

java - "Simple"矩形碰撞检测 : Why doesn't my code work?

android - 由于 Resources$NotFoundException,应用程序在 android API 10 上启动时崩溃,但在 API 16 上不会崩溃

android - 在 Android 2.3 .X (Gingerbread) 及更低版本上修改 LayerDrawable 层

android - 如何在 Android 中将 <vector> 放入 <shape> 中?

android - 有没有办法检测 Android Wear Watch 上的 Location is OFF 而不是不存在

java - 空对象引用上的 View.findViewById(int)'

php - 安卓通知火力基地

android - Android中如何将位图图片保存到Drawable文件夹中