2016-08-22 53 views
7

這些都包含在整個應用程序的文本方面?TextColor vs TextColorPrimary vs TextColorSecondary

更具體地說,在整個我的應用程序的主題變化中會改變這些變化的每一個?我希望我的按鈕的文字與我的文字瀏覽不同,是一個主要的,另一個是次要的?

任何與這些條款相關的信息將不勝感激!

回答

10

TextColor只是xml屬性,用於將顏色設置爲任何給定視圖的文本。

TextColorPrimary是啓用的按鈕和大文本視圖的默認文本顏色。

TextColorSecondary是中文和小文字視圖的默認文本顏色。

忽略這一點,至於你想做什麼,還有更好的方法。你想編輯你的style.xml,使默認主題AppTheme(或者你在清單中聲明爲主題的其他任何東西)包含必要的xml屬性來定製你的文本顏色。

完成後,生成的AppTheme樣式將如此。

<!-- Base application theme. --> 
<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> 
    <item name="android:textColor">#hexColorForTextViews</item> 
    <item name="android:buttonStyle">@style/myDefaultButton</item> 
</style> 

textColor將設置所有文字瀏覽的默認顏色。 buttonStyle將引用您想要的所有按鈕的自定義樣式。要做到這一點,請將此樣式標籤添加到styles.xml文件中。

<style name="myDefaultButton"> 
    <item name="android:textColor">#hexColorForButtons</item> 
    <!-- other stuff you want your buttons to inherit by default --> 
</style> 
相關問題