歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android的布景設計(theme)

Android的布景設計(theme)

日期:2017/3/1 10:21:45   编辑:Linux編程
布景是可以大范圍套用的UI美化功能,它的范圍為整個屏幕,從程序編碼的角度來看,布景可以套用到以下兩個范圍:
  • 整個應用程序(application)
  • 整個Activity

下面是一個套用整個application布景的例子,自定義一個不顯示窗口標題,並改變應用程序的背景顏色。

相關閱讀:Android事件監聽器(Event Listener) http://www.linuxidc.com/Linux/2012-05/61186.htm

延續上個工程(見 http://www.linuxidc.com/Linux/2012-05/61362.htm ),編輯style.xml:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3. <style name="myText">
  4. <item name="android:textSize">18sp</item>
  5. <item name="android:textColor">#00FF00</item>
  6. </style>
  7. <style name="myButton">
  8. <item name="android:background">#00BFFF</item>
  9. </style>
  10. <style name="myTheme">
  11. <item name="android:windowNoTitle">true</item>
  12. <item name="android:background">#087832</item>
  13. </style>
  14. </resources>
修改AndroidManifest.XML,在application中加入theme屬性:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.android"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk android:minSdkVersion="10" />
  7. <application
  8. android:theme="@style/myTheme"
  9. android:icon="@drawable/ic_launcher"
  10. android:label="@string/app_name" >
  11. <activity
  12. android:name=".YypClickListenerActivity"
  13. android:label="@string/app_name" >
  14. <intent-filter>
  15. <action android:name="android.intent.action.MAIN" />
  16. <category android:name="android.intent.category.LAUNCHER" />
  17. </intent-filter>
  18. </activity>
  19. </application>
  20. </manifest>
Copyright © Linux教程網 All Rights Reserved