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