【问题标题】:Appcompat Theme not applied on all WidgetsAppcompat 主题不适用于所有小部件
【发布时间】:2015-05-08 05:40:58
【问题描述】:

我已经扩展了 Material Theme 并将其应用到我的活动中。

在 style.xml 中

  <style name="AppTheme" parent="Theme.AppCompat.NoActionBar"> 
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>
        <item name="android:windowBackground">@color/bg</item>
    </style>`

和 在清单中

    <application
        android:allowBackup="true"
        android:theme="@style/AppTheme"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name" >
...</application>

我在工具栏、按钮上看到了 Material design 样式,但它不适用于 Pre Lollipop 设备中的 ImageButton、ToggleButton 和 Seekbar。它们出现在 Holo 主题中。

在我正在使用的 gradle 文件中:

compile 'com.android.support:appcompat-v7:22.1.1'

我应该怎么做才能对所有小部件应用统一样式??

【问题讨论】:

    标签: android android-theme android-appcompat


    【解决方案1】:

    根据blog post,目前支持以下小部件:

    • AppCompatAutoCompleteTextView
    • AppCompatButton
    • AppCompatCheckBox
    • AppCompatCheckedTextView
    • AppCompatEditText
    • AppCompatMultiAutoCompleteTextView
    • AppCompatRadioButton
    • AppCompatRatingBar
    • AppCompatSpinner
    • AppCompatTextView

    对于ToggleButton,您可以尝试改用SwitchCompat

    【讨论】:

    • 正如博客中提到的,这不只是着色感知的小部件列表吗?不管怎样,我正在尝试它们。
    • 无论如何,所有这些组件都出现在材料设计中。不幸的是,对我来说仍然是旧主题的那些不受支持。已按照您的建议更改了 ToggleButton。还是得为 Seekbar 和 Imagebutton 做点什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-30
    • 2015-02-07
    • 2019-11-09
    • 2014-10-22
    • 2014-08-12
    • 1970-01-01
    相关资源
    最近更新 更多