【问题标题】:Custom CheckBox style自定义复选框样式
【发布时间】:2013-03-20 17:54:11
【问题描述】:

我在http://android-holo-colors.com/ 上为我的Android 应用创建了一些样式。我已经下载了它并将其解压缩到我的 res 文件夹中,但我无法管理它来应用复选框的样式。这是我在自定义主题中所做的。

<style name="CustomTheme" parent="Theme.Sherlock.Light">
    ...
    <item name="android:checkboxStyle">@style/CheckBoxAppTheme</item>
    ...
</style>

我应用的样式是由android-holo-colors生成的,所以我认为错误不应该是这种样式。有谁看到我做错了什么?顺便提一句。主题应用于应用程序。

更新:

为了更清楚,我也将发布样式的代码。

<style name="CheckBoxAppTheme" parent="android:Widget.CompoundButton.CheckBox">
    <item name="android:button">@drawable/btn_check_holo_light</item>
</style>

那里使用的drawable有一个看起来像这样的选择器:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Enabled states -->

    <item android:state_checked="true" android:state_window_focused="false"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_on_holo_light" />
    <item android:state_checked="false" android:state_window_focused="false"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_off_holo_light" />

    <item android:state_checked="true" android:state_pressed="true"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_on_pressed_holo_light" />
    <item android:state_checked="false" android:state_pressed="true"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_off_pressed_holo_light" />

    <item android:state_checked="true" android:state_focused="true"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_on_focused_holo_light" />
    <item android:state_checked="false" android:state_focused="true"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_off_focused_holo_light" />

    <item android:state_checked="false"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_off_holo_light" />
    <item android:state_checked="true"
          android:state_enabled="true"
          android:drawable="@drawable/btn_check_on_holo_light" />

    <!-- Disabled states -->

    <item android:state_checked="true" android:state_window_focused="false"
          android:drawable="@drawable/btn_check_on_disabled_holo_light" />
    <item android:state_checked="false" android:state_window_focused="false"
          android:drawable="@drawable/btn_check_off_disabled_holo_light" />

    <item android:state_checked="true" android:state_focused="true"
          android:drawable="@drawable/btn_check_on_disabled_focused_holo_light" />
    <item android:state_checked="false" android:state_focused="true"
          android:drawable="@drawable/btn_check_off_disabled_focused_holo_light" />

    <item android:state_checked="false"
          android:drawable="@drawable/btn_check_off_disabled_holo_light" />
    <item android:state_checked="true" 
          android:drawable="@drawable/btn_check_on_disabled_holo_light" />

</selector>

那里使用的所有drawables都是.png文件。

【问题讨论】:

    标签: android checkbox styles


    【解决方案1】:

    您是否更改了 AndroidManifest.xml 中的应用主题?

    【讨论】:

      【解决方案2】:

      您确定您的文件放置在正确的文件夹中吗?

      注意:注意不要将“drawable-XXX”文件夹与“mipmap-XXX”文件夹(其中包含应用程序的图标)混淆。

      【讨论】:

        猜你喜欢
        • 2011-02-07
        • 2017-10-28
        • 1970-01-01
        • 2020-04-18
        • 1970-01-01
        • 2011-06-07
        • 2021-05-20
        • 2020-05-28
        相关资源
        最近更新 更多