【发布时间】:2011-11-23 07:56:12
【问题描述】:
我无法使用预定义的样式设置按钮的文本颜色。我一定错过了一些简单的东西。例如,我有一个按钮:
<Button
android:id="@+id/calculate_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/calculate"
android:background="@drawable/rounded_bottom_shape"
android:padding="5dp"
android:textAppearance="@style/CalcResultStyle">
</Button>
而对应的样式是:
<style name="CalcResultStyle">
<item name="android:textSize">12sp</item>
<item name="android:textColor">#FFF</item>
</style>
尺寸部分效果很好,但颜色却不行。我发现的唯一解决方法是在实际按钮上设置 textColor,这意味着更改多个按钮的颜色变得很痛苦。我也更喜欢在我的样式中使用颜色参考设置 textColor 属性,例如 @color/Brown,但使用参考或显式设置颜色似乎没有任何区别。
【问题讨论】:
-
其实按钮文本默认是黑色的。请阅读我的问题。
-
啊对了,列表视图和其他项目都是黑底白字。
标签: android xml styles textcolor