My Android Advanced tour------> How do I turn activity into a translucent dialog box? There are two aspects to consider: dialog box and translucent.
You can set activity as a dialog style by specifying the Theme.dialog theme when you define the activity.
You can change the background image of an activity by modifying the Android:windowbackground property value of the Theme.dialog theme. If the background image uses a translucent image, the activity becomes a translucent dialog box. In order to modify the Android:windowbackground property, you can define a new theme that inherits from the Theme.dialog code as follows:
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 a custom theme for the 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 a custom 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
==================================================================================================
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
My Android Advanced tour------> How do I turn activity into a translucent dialog box?