【问题标题】:How to use the Material Design Theme on pre Android 5.0 Devices如何在 Android 5.0 之前的设备上使用 Material Design 主题
【发布时间】:2014-11-21 09:25:17
【问题描述】:

我正在启动一个应该使用材料设计主题的应用程序。

但该项目的 minSDK 是 api 级别 15。

如何设置应用以在较低版本的 Android 上尽可能多地使用 Material Design?

【问题讨论】:

标签: android material-design android-5.0-lollipop


【解决方案1】:

我按照 Dodge 推荐的指南进行操作。

添加

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

到您的依赖项。

现在将样式放入您的值文件夹:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/primary</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/primary_dark</item>

        <!-- colorAccent is used as the default value for colorControlActivated
             which is used to tint widgets -->
        <item name="colorAccent">@color/accent</item>

        <!-- You can also set colorControlNormal, colorControlActivated
             colorControlHighlight & colorSwitchThumbNormal. -->

    </style>

</resources>

现在您必须将其添加到清单中的应用程序中:

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

此设置继承自 NoActionBar 主题,因此也可以使用兼容工具栏。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-07
    • 2015-04-01
    • 2014-12-21
    • 2023-03-18
    • 2014-11-25
    • 2015-01-01
    • 2015-01-15
    相关资源
    最近更新 更多