<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!--主色調(diào) -->
<item name="colorPrimary">@color/colorPrimary</item>
<!--狀態(tài)欄顏色-->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<!--控制各個(gè)控件被選中時(shí)的顏色-->
<item name="colorAccent">@color/colorAccent</item>
<!--頁(yè)面背景色-->
<item name="android:windowBackground">@color/colorWindowBg</item>
<!--底部導(dǎo)航欄顏色-->
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
<!--ToolBar上的Title顏色-->
<item name="android:textColorPrimary">@color/colorText</item>
<!--各個(gè)控制控件的默認(rèn)顏色 與colorAccent相反-->
<item name="android:colorControlNormal">@color/colorPrimary</item>
<!--控制所有可點(diǎn)擊的View的漣漪效果顏色-->
<item name="android:colorControlHighlight">@color/colorCheck</item>
<!--控制normal狀態(tài)下button的顏色-->
<item name="android:colorButtonNormal">@color/colorPrimary</item>
<!--EditText 輸入框中字體的顏色-->
<item name="editTextColor">@color/colorText</item>
</style>
相關(guān)屬性說(shuō)明
- colorPrimary: Toolbar導(dǎo)航欄的底色铅乡。
- colorPrimaryDark:狀態(tài)欄的底色继谚,注意這里只支持Android5.0以上的手機(jī)。
- textColorPrimary:整個(gè)當(dāng)前Activity的字體的默認(rèn)顏色。
- android:windowBackground:當(dāng)前Activity的窗體顏色花履。
- colorAccent:CheckBox芽世,RadioButton,SwitchCompat等控件的點(diǎn)擊選中顏色
- colorControlNormal:CheckBox诡壁,RadioButton济瓢,SwitchCompat等默認(rèn)狀態(tài)的顏色。
- colorButtonNormal:默認(rèn)狀態(tài)下Button按鈕的顏色妹卿。
- editTextColor:默認(rèn)EditView輸入框字體的顏色旺矾。
特別介紹
下面我們要說(shuō)的是其他一些和顏色相關(guān)的屬性,這些屬性可能你平時(shí)并不常用夺克,但合理運(yùn)用它們不僅可以使你的界面更加絢麗而且可以達(dá)到事半功倍的效果箕宙。(再次聲明以下屬性適用于5.0及其以上系統(tǒng))
1、colorControlHighlight
colorControlHighlight用于控制所有可點(diǎn)擊的View的漣漪效果顏色铺纽,以button舉例來(lái)說(shuō)
2柬帕、colorButtonNormal
用于控制normal狀態(tài)下button的顏色(注意和button的background屬性的區(qū)別,設(shè)置colorButtonNormal后button依舊會(huì)具有漣漪效果狡门,而設(shè)置background就沒(méi)有漣漪效果了)
3陷寝、android:navigationBarColor
控制底部導(dǎo)航欄的背景色(注意前邊必須有android:)
常用控件顏色屬性
EditText
- unfocused —— colorControlNormal
- focus —— colorAccent
- cursor —— colorAccent
- text color —— android:textColorPrimary
RadioButton
- unselected —— colorControlNormal
- selected —— colorAccent
CheckBox
- box unchecked —— colorControlNormal
- box checked —— colorAccent
Toolbar
- background —— 布局文件中設(shè)置android:background="?attr/colorPrimary
- overflow icon —— android:textColorPrimary
- navigation icon —— android:textColorPrimary
- action icons —— android:textColorPrimary
- overflow menu background —— android:colorBackground
- overflow text color —— android:textColorPrimary
ActionBar
- background —— colorPrimary
- title color —— android:textColorPrimary
- overflow icon —— android:textColorPrimary
- up button —— android:textColorPrimary
- action icons —— android:textColorPrimary
- overflow menu background —— android:colorBackground
- overflow text color —— android:textColorPrimary
Spinner
- indicator (not pressed) —— colorControlNormal
- indicator (pressed) —— colorAccent
- selected entry text color —— "android:textColorPrimary
SwitchCompat
- thumb switch off —— colorSwitchThumbNormal
- thumb switch on —— colorAccent
- track overlay —— colorAccent"