2
如何在主屏幕小部件中的TextView中更改字体样式?如何更改主屏幕小部件中的TextView字体样式?
如何在主屏幕小部件中的TextView中更改字体样式?如何更改主屏幕小部件中的TextView字体样式?
如果你在运行时的意思是,一个简单的方法是:
文字大小
yourRemoteView.setFloat(R.id.textview, "setTextSize", 30);
文本颜色
yourRemoteView.setInt(R.id.textview, "setTextColor", Color.RED);
像这样:
首先,在values/styles.xml
定义文本样式:
<resources>
<style name="AppTheme" parent="android:style/Theme.Light">
....
</style>
<style name="WidgetEntryTitle" parent="style/AppTheme">
<item name="android:textSize">24sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="WidgetEntryDate" parent="style/AppTheme">
<item name="android:textSize">20sp</item>
<item name="android:textColor">@android:color/black</item>
</style>
</resources>
然后,使用样式mywidget_layout.xml
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
...>
<TextView style="@style/WidgetEntryTitle"
... />
<TextView style="@style/WidgetEntryDate"
... />
</RelativeLayout>
我不是那个意思,但感谢你的建议! – Sparky 2012-03-07 20:10:14