我无法使用预定义的样式设置按钮的文本颜色。我一定是错过了什么简单的东西。例如,我有一个按钮:
<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,这意味着更改多个按钮的颜色会变得很麻烦。我还喜欢使用颜色引用(例如@color/Brown)在我的样式中设置textColor属性,但使用引用或明确设置颜色似乎没有任何区别。