android 窗口背景透明方法

    在Android应用开发中,使用系统桌面背景作为应用的背景,需要把应用的背景设置为透明背景,然后设置窗口的属性为FLAG_SHOW_WALLPAPER即可显示背景。

修改AndroidManifest.xml文件里面activity属性:

         <activity android:name=".WallPaperTest"
          android:label="@string/app_name"        

          android:theme="@android:style/Theme.Translucent">

然后在使用的时候,在onCreate里面添加一个窗口属性,(注意这句话添加在setContentView(R.layout.×××)后面)getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);

你可能感兴趣的:(android)