標籤:3.3 定義 cti launch round 半透明 white 背景圖 art
我的Android進階之旅------>怎樣將Activity變為半透明的對話方塊?能夠從兩個方面來考慮:對話方塊和半透明。
在定義Activity時指定Theme.Dialog主題就能夠將Activity設定為對話方塊風格。
通過改動Theme.Dialog主題的android:windowBackground屬性值能夠改變Activity的背景映像。
假設背景映像使用半透明的映像,則Activity就好變成半透明的對話方塊。為了改動android:windowBackground屬性,能夠定義一個新的主題,該主體繼承自Theme.Dialog,代碼例如以下:
在res/values下建立兩個xml檔案。一個為主題風格資源dialog_styles.xml。
一個為顏色資源dialog_colors.xml。
dialog_styles.xml,主題風格名為 dialog_translucent
<?xml version="1.0" encoding="utf-8"?><resources> <style name="dialog_translucent" parent="@android:style/Theme.Dialog"> <item name="android:windowBackground">@color/translucent_background</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item<span style="white-space:pre"></span>> </style></resources>
dialog_colors.xml
<?xml version="1.0" encoding="utf-8"?><resources> <color name = "translucent_background">#00000000</color></resources>
在AndroidManifest.xml為Activity指定自己定義的主題,android:theme="@style/dialog_translucent"
代碼例如以下:
<activity android:name=".DialogActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name" android:theme="@style/dialog_translucent" ><!-- 引用自己定義的主題 -->> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
==================================================================================================
歐陽鵬 歡迎轉載,與人分享是進步的源泉!
轉載請保留原文地址:http://blog.csdn.net/ouyang_peng
==================================================================================================
我的Android進階之旅------>怎樣將Activity變為半透明的對話方塊?