Android的布景设计(theme)

来源:互联网 发布:藏头诗在线生成器软件 编辑:程序博客网 时间:2024/05/01 04:16
布景是可以大范围套用的UI美化功能,它的范围为整个屏幕,从程序编码的角度来看,布景可以套用到以下两个范围:
  • 整个应用程序(application)
  • 整个Activity

下面是一个套用整个application布景的例子,自定义一个不显示窗口标题,并改变应用程序的背景颜色。

延续上个工程,编辑style.xml:

<?xml version="1.0" encoding="utf-8"?><resources>    <style name="myText">        <item name="android:textSize">18sp</item>        <item name="android:textColor">#00FF00</item>    </style>    <style name="myButton">        <item name="android:background">#00BFFF</item>    </style>    <style name="myTheme">    <item name="android:windowNoTitle">true</item>     <item name="android:background">#087832</item>           </style>     </resources>

修改AndroidManifest.XML,在application中加入theme属性:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.android"    android:versionCode="1"    android:versionName="1.0" >    <uses-sdk android:minSdkVersion="10" />    <application        android:theme="@style/myTheme"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name" >        <activity            android:name=".YypClickListenerActivity"            android:label="@string/app_name" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application></manifest>

程序运行效果: