2014-11-21 134 views
2

我開始使用材質設計主題的應用程序。如何在Android 5.0設備上使用材質設計主題

但minSDK該項目是API級別15

如何設置應用程序使用盡可能多的材料設計儘可能Android上的低版本?

+0

你可以在這裏找到它,backport:http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html – 2014-11-21 09:28:17

回答

1

我遵循了道奇推薦的指南。

添加

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主題繼承,使之也可以使用compat Toolbar。