我正在编写一款安卓应用程序,想要改变它的主题。
我已经通过使用一个主题来改变了应用程序的背景颜色,但是我无法更改默认文本外观。
这是我的styles.xml资源文件。
<resources>
<style name="QTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/q_green</item>
<item name="android:colorBackground">@color/q_green</item>
<item name="android:textAppearance">@style/QText</item>
</style>
<color name="q_green">#008000</color>
<color name="white">#FFFFFF</color>
<style name="QText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">20sp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
<item name="android:textFont">Verdana</item>
</style>
</resources>
仅作检查,这是我其中一个TextViews的示例,我想在我的布局文件中使用上述样式。
<TextView
android:id="@+id/txtDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/device"
/>
有谁能看出我错在哪里了吗?
TextAppearance.Medium
样式(这不会修改TextView
的外观)。如果你想修改TextView
的外观,则应该在主题中覆盖textViewStyle
样式属性。或者你可以使用android:textAppearance
来应用你的自定义样式。 - userSpinner
的TextView
项目具有不同的样式(仍继承自TextView
样式),由主题中的spinnerItemStyle
属性指定。您可能希望将其设置为@android:style/Widget.TextView.SpinnerItem
,然后查看效果如何。 - user