Settings for Android transparency (transparent translucent)

Source: Internet
Author: User

The setting parameter of drawable is int: The setting parameter of 0~255,view is float value: 0~1

To set the transparency by drawable:

In OnCreate () of activity, after Setcontentview (), add the following code:
int
color =new colordrawable (color);d rawable.setalpha(),GetWindow (). Setbackgrounddrawable (drawable);

Settings for the transparency of a view directly:

View view = Findviewbyid (); View.setalpha (float); // Float value Range 0~1

For activity, you can also set the translucency by using the style:

<?xml version= "1.0" encoding= "Utf-8"?><resources>    <style name= "theme.transparent" parent= " Android:theme ">        <item name=" Android:windowistranslucent ">true</item>        <item Name= "Android:windowbackground" > @android:color/transparent</item>        <item name= "Android: Windownotitle ">true</item>    </style></resources>//  Add <activity android:name= ".... youractivity" to the Activity property in the Manifest.xml file "     android: Screenorientation= "Portrait"     android:theme= "@style/theme.transparent"/>

Settings for Android transparency (transparent translucent)

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.