Material主題帶來的效果體現在以下幾個方面:
- System widgets that let you set their color palette(調色板)
- 系統控件(部件)的觸屏反饋動畫
- Activity跳轉動畫
系統提供的主題樣式:
@android:style/Theme.Material
(dark version)@android:style/Theme.Material.Light
(light version)@android:style/Theme.Material.Light.DarkActionBar
自定義Color Palette
<resources> <!-- 繼承自material theme --> <style name="AppTheme" parent="android:Theme.Material"> <!-- Main theme colors --> <!-- your app branding color for the app bar --> <item name="android:colorPrimary">@color/primary</item> <!-- darker variant for the status bar and contextual app bars --> <item name="android:colorPrimaryDark">@color/primary_dark</item> <!-- theme UI controls like checkboxes and text fields --> <item name="android:colorAccent">@color/accent</item> </style> </resources>
colorPrimaryDark - 這是app中最黑的基本色,主要用來做notification bar的背景.
colorPrimary - 這是app的基本顏色,將用作toolbar的背景色
textColorPrimary - 文本顏色,用於toolbar的標題
windowBackground - app默認的背景顏色
自定義狀態欄
<!-- 繼承自material theme --> <style name="AppTheme" parent="android:Theme.Material"> <!-- Main theme colors --> <!-- ... --> <item name="android:statusBarColor">自定義顏色值</item> <!-- ... --> </style> </resources>