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)