如何在Android 5.0之前的设备上使用Material Design主题

时间:2014-11-21 09:25:17

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

我正在创建一个应该使用材质设计主题的应用。

但该项目的minSDK是api level 15.

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

1 个答案:

答案 0 :(得分:1)

我按照道奇推荐的指南。

添加

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

到您的依赖项。

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

<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主题,以便也可以使用compat工具栏。

相关问题