Java Android-按钮文本颜色未被覆盖
我的主题是:Java Android-按钮文本颜色未被覆盖,java,android,Java,Android,我的主题是: <style name="AppTheme" parent="Theme.AppCompat.Light"> <item name="android:windowContentOverlay">@null</item> <item name="actionBarTheme">@style/MyActionBarTheme</item> <item name="actionBarStyle"&g
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowContentOverlay">@null</item>
<item name="actionBarTheme">@style/MyActionBarTheme</item>
<item name="actionBarStyle">@style/MyActionBarStyle</item>
<item name="circularProgressBarStyle">@style/CircularProgressBar</item>
<item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="actionMenuTextColor">@color/white</item>
<item name="actionBarTabBarStyle">@style/MyActionBarTab</item>
</style>
@空的
@风格/动作风格
@样式/MyActionBarStyle
@样式/循环压杆
@样式/MyActionBarTabText
@颜色/白色
@style/MyActionBarTab
我在这里没有看到任何样式会影响我的按钮文本颜色,因为它们是用于动作栏样式的。但我仍然无法更改布局文件中的按钮文本颜色:
<Button
...
android:textSize="22sp"
android:textColor="@color/yellow"
... />
我可以在这里更改
textSize
,但不能更改textColor
。谁能告诉我为什么?这不应该是造型的最高优先级吗?(这意味着覆盖style.xml配置(如果有)。如果我错了,请纠正我。非常感谢 这就是你应该做的:
android:textColor="@android:color/yellow"
而不是
android:textColor="@color/yellow"
这就是你应该做的:
android:textColor="@android:color/yellow"
而不是
android:textColor="@color/yellow"
setTextColor(getApplication().getResources().getColor(R.color.green))
button.setTextColor(Color.parseColor(#ff1100”) button.setTextColor(getApplication().getResources().getColor(R.color.green))
button.setTextColor(Color.parseColor(#ff1100”) 将此添加到您的样式中
<item name="colorButtonNormal">@color/colorPrimary</item>
@color/colorPrimary
或
您可以像这样将属性android:background添加到button类
<Button
...
android:textSize="22sp"
android:background="@color/yellow"
... />
将此添加到您的风格中
<item name="colorButtonNormal">@color/colorPrimary</item>
@color/colorPrimary
或
您可以像这样将属性android:background添加到button类
<Button
...
android:textSize="22sp"
android:background="@color/yellow"
... />
正如TejjD所说:
这就是你应该做的:
android:textColor="@android:color/yellow"
android:textColor=“@android:color/yellow”而不是
android:textColor=“@color/yellow”
您必须在Colors.xml文件中定义自定义颜色。正如TejjD所说:
这就是你应该做的:
android:textColor="@android:color/yellow"
android:textColor=“@android:color/yellow”而不是
android:textColor=“@color/yellow”
你必须在Colors.xml文件中定义你的自定义颜色。你可以应用自定义样式复制样式并修改它并应用到按钮。你能显示
@color/yellow
@PhanVănLinh nope吗,但我想通过在color.xml
中应用选择器
来实现它,声明“启用”和“禁用”具有相同的颜色…虽然这是一个愚蠢的解决方案,但您可以应用自定义样式复制样式并修改它并应用于按钮。您是否可以显示@color/yellow
@PhanVănLinh nope,但我想通过在color.xml
中应用选择器使其工作,声明enable和disable都有相同的颜色…虽然这是一个愚蠢的解决方案,但实际上我想在参考资料中保留UI配置,而不是将其放在逻辑代码中试试这个…它会起作用,但实际上我想把UI配置保存在参考资料中,而不是放在逻辑代码中试试这个…但那是Android框架的颜色,我想用我自己的颜色,但那是Android框架的颜色,我想用我自己的颜色