【发布时间】:2016-08-12 07:42:09
【问题描述】:
在styles.xml 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"/>
问题是某些东西不起作用,因为自定义文本视图正在以我的自定义主题的默认颜色(白色)而不是我为该文本视图的自定义样式指定的自定义颜色(绿色)显示。
我做错了什么?
【问题讨论】:
-
style="style/CustomTextView" -> style="@style/CustomTextView"
标签: android android-layout textview android-theme android-styles