Android: Set activity to pop-up and transparent

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.