我正在开发一个
Android应用程序,我想改变应用程序的颜色和主题.我怎样才能做到这一点?
解决方法
Dev guide explains how to apply themes and styles.
这个:
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00FF00" android:typeface="monospace" android:text="@string/hello" />
变成这样:
<TextView style="@style/CodeFont" android:text="@string/hello" />
通过定义xml主题文件:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#00FF00</item> <item name="android:typeface">monospace</item> </style> </resources>
您还可以将样式应用于应用程序的所有活动:
<application android:theme="@style/CustomTheme">
或者只是一项活动:
<activity android:theme="@android:style/Theme.Dialog">
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。