My Android Advanced tour------> How do I turn activity into a translucent dialog box? Can be considered from two aspects: dialog box and translucent.
Specifying the Theme.dialog theme when you define an activity enables you to set activity as a dialog style.
You can change the background image of an activity by altering the Android:windowbackground property value of the Theme.dialog theme.
Assuming the background image uses a translucent image, the activity becomes a translucent dialog box. In order to change the Android:windowbackground property, it is possible to define a new theme that inherits from the Theme.dialog code, such as the following:
Create two XML files under Res/values. One for theme style resources Dialog_styles.xml.
One for the color resource dialog_colors.xml.
Dialog_styles.xml, themed style named 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>
Specify the topic you define for activity in Androidmanifest.xml,Android:theme= "@style/dialog_translucent"
The code is as follows:
<activity android:name= ". Dialogactivity " android:configchanges=" orientation|keyboardhidden|screensize " android:label=" @string/ App_name " android:theme=" @style/dialog_translucent "><!--reference your own defined theme-->> <intent-filter > <action android:name= "Android.intent.action.MAIN"/> <category android:name= " Android.intent.category.LAUNCHER "/> </intent-filter> </activity>
==================================================================================================
Ouyangpeng welcome reprint, sharing with people is the source of progress!
Reprint please keep the original address : Http://blog.csdn.net/ouyang_peng
==================================================================================================
My Android Advanced tour------> How do I turn activity into a translucent dialog box?