Android sets the form transparency

Source: Internet
Author: User

1. Set the form transparency.

Windowmanager. layoutparams Lp = getwindow (). getattributes ();
LP. Alpha = 0.5f;
Getwindow (). setattributes (LP );
Alpha is between 0.0f and 1.0f.

2. Set the darkness.

Windowmanager. layoutparams Lp = getwindow (). getattributes ();
LP. dimamount = 0.5f;
Getwindow (). setattributes (LP );
Getwindow (). addflags (windowmanager. layoutparams. flag_dim_behind );
Dimamount is between 0.0f and 1.0f.

3. Set background blur
Getwindow (). setflags (windowmanager. layoutparams. flag_blur_behind,
Windowmanager. layoutparams. flag_blur_behind );

4. Call the view method view =...
View. getbackground (). setalpha (100); // 0 ~ 255 transparency value, 0 is completely transparent, 255 is not transparent

5. Add the following content to the activity attribute configuration in the configuration file:
Android: theme = "@ Android: style/theme. translucent"
In this way, the android transparent style is called!

OK. That's all. Add more later.

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.