0

在styles.xml appTheme指定有默認textColor屬性:如何覆蓋自定義textView樣式顏色的AppTheme textColor?

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <item name="android:textColor">@color/colorFontWhite</item> 
    </style> 

這是對子級完美的,如果有可能覆蓋它使用在styles.xml文件,這個新項目所需的一些情況:

<style name="CustomTextView" parent="@android:style/Widget.TextView"> 
     <item name="android:textColor">@color/colorFontGreen</item> 
    </style> 

並指定其所需的TextView XML佈局是這樣的:

<TextView 
     android:id="@+id/text"  
     style="style/CustomTextView"/> 

的問題是,什麼是不行的,因爲自定義正在使用我的自定義主題(白色)的默認顏色顯示textview,而不是使用該自定義樣式爲該文本視圖(綠色)指定的自定義顏色。

我在做什麼錯?

感謝

+0

風格= 「風格/ CustomTextView」 - >風格= 「@風格/ CustomTextView」 – Shaishav

回答

3

如果你指的是資源類型(風格在這種情況下),你需要使用的符號(@)。

更改如下:

style="style/CustomTextView" 

要這樣:

style="@style/CustomTextView" 
+0

非常感謝你!如果谷歌廣告編譯時間錯誤或皮棉標記與這些類型的錯誤會更好:) – NullPointerException

相關問題