Android Set Background transparency

Source: Internet
Author: User
Tags set background

At some point, we need to set the background color for the UI page, for example, as seen in:

Note: The background color is #000000 and the transparency is 40%; How do you say it in code?

The first thing you need to know: the color and opacity (alpha) values are represented in hexadecimal notation. Regardless of the value range of a color is 0 to 255 (00 to FF). For alpha,00 to be completely transparent, FF is completely opaque.

The expression order is "AABBGGRR", in which Aa=alpha (00 to FF). Bb=blue (00 to FF). Gg=green (00 to FF). Rr=red (00 to FF). Like what. Suppose you want to apply a blue 50% opacity to an overlay, you should specify the lower face value: 7fff0000.

So how do you calculate the value of transparency? Take 40% as an example:

Calculation formula: 40*255/100= ... Convert to 16, can use calculator:


Did you see that. The alpha value of 40% is converted to 66; The value of the background to set the view in code is: #66000000


That's OK. Please correct me.
If in doubt, Welcome to QQ Group: 487786925 (Android Research and Development village)

Android Set Background transparency

Related Article

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.