1.Material Deisgn的Theme
- @android:style/Theme.Material(dark version)
- @android:style/Theme.Material.Light(light version)
- @android:style/Theme.Material.Light.DarkActionBar
與之對應的Compat Theme:
- Theme.AppCompat
- Theme.AppCompat.Light
- Theme.AppCompat.light.DarkActionBar
(1)個性化Color Palette
我們可以根據(jù)我們的app風格,去制定Color Palette(調色板)为迈,重點有以下幾個屬性:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
- colorPrimary對應的ActionBar的顏色梗顺;
- colorPrimaryDark對應的狀態(tài)欄的顏色蛉签;
- colorAccent對應的EditText編輯時、RadioButton選中凸克、CheckBox等選中時的顏色荒澡;
與之對應的圖:
20150427034747930.png
注:對于5.0以下的設備,目前colorPrimaryDark無法個性化狀態(tài)欄的顏色寝殴,底部的navagationBar可能也不一樣,更別說設置顏色了明垢。
2.實例Demo
values/styles.xml
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorPrimary">@color/material_blue_500</item>
<item name="colorPrimaryDark">@color/material_blue_700</item>
<item name="colorAccent">@color/material_green_A200</item>
</style>
values-v21/styles.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:statusBarColor">@color/material_blue_700</item>
</style>
vlaues/colors.xml
<color name="material_blue_500">#009688</color>
<color name="material_blue_700">#00796B</color>
<color name="material_green_A200">#FD87A9</color>
效果展示:
QQ圖片20170123110126.png
注:colorAccent就是圖中的粉色,EditText正在輸入時市咽,RadioButton選中時的顏色痊银。
參考文章: