1. Create color. xml under res/values
<Resources> <color name = "transparent_background"> #80 ffffff </color>
</Resources> PS: #80 is the transparency value (80% transparency), and ffffff is the color value (black)
2. Create style. xml under res/values
<Resources> <style name = "Transparent" parent = "android: style/Theme. dialog "> <item name =" android: windowBackground "> @ color/transparent_background </item> <item name =" android: windowNoTitle "> true </item> <item name =" android: javaswistranslucent "> true </item> <item name =" android: windowAnimationStyle ">@+ android: style/Animation. translucent </item> </style> </resources> PS: parent = "android: style/Theme. dialog "sets activity as a pop-up window.
3. Find the activity to be popped up in AndroidManifest. xml and add theme:
<Activity android: name = "ActivityName" android: theme = "@ style/Transparent"/> after completing the preceding settings, your activity is Transparent, however, the controls in the Activity are not transparent. If the controls are still transparent, add the following code to the code of the activity:
// Set the transparent Window window of the control in the activity = getWindow (); WindowManager. layoutParams wl = window. getAttributes (); wl. flags = WindowManager. layoutParams. FLAG_KEEP_SCREEN_ON; wl. alpha = 0.95f; // set transparency. The value 0.0 indicates full transparency, and the value 1.0 indicates full opacity window. setAttributes (wl );