There are about three ways to set the transparency effect1, using the Android system's transparent effect Java code android:background= "@android: Color/transparent"For example, set the button Java code<button android:background= "@android: Color/transparent"Android:text= "@+id/button01"Android:id= "@+id/button01"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:textcolor= "#ffffff"/> 2, using ARGB to control the Java code translucency<button android:background= "#e0000000"/>Transparent<button android:background= "#00000000"/> 3, set Alphajava code View v= Findviewbyid (r.id.content);//find the ID of the layout you want to set the transparent background toV.getbackground (). Setalpha (100);//0~255 Transparency ValueAndroid forms transparent, dark and so on settings tricks set Transparency (this is the transparency of the form itself, non-background)1Windowmanager.layoutparams LP=GetWindow (). GetAttributes ();2Lp.alpha=0.3f;3GetWindow (). SetAttributes (LP); Alpha is between 0.0f and 1.0f. 1.0 completely opaque, 0. 0f completely transparent set the dark degreeWindowmanager.layoutparams LP=GetWindow (). GetAttributes ();Lp.dimamount=0.5f;GetWindow (). SetAttributes (LP);GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_DIM_BEHIND);d imamount between 0.0f and 1.0f,0.0f is completely dark, 1. 0f all Dark set background blurGetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_BLUR_BEHIND,WindowManager.LayoutParams.FLAG_BLUR_BEHIND); settings for transparent, translucent effects of the same active activity as the Dialog dialog box Transparentres/values/Styles.xml
<resources> <style name= "Transparent" > <item name= "Android:windowbackground" >@color/Transparent_background</item> <item name= "Android:windownotitle" >true</item> <item name= "Android:windowistranslucent" >true</item> <item name= "Android:windowanimationstyle" > @+android:style/animation.translucent</item> </style> </resources>Res/values/Color.xml<?xml version= "1.0" encoding= "Utf-8"?> <resources> <color name= "Transparent_background" > #50000000 </color> </resources>//Note://the first two bits of the color.xml #5000000 are transparent effect parameters from 00--99 (transparent-not very transparent),//The post 6 bit is the color settingmanifest.xml<Activity Android:name=". Transparentactivity "Android:theme= "@style/transparent" > </activity>Java Code Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); SetTheme (r.style.transparent); Setcontentview (r.layout.transparent); The configuration ends.
Android settings transparent, translucent and other effects