您的位置:首页 > 其它

设置当前Activity背景是当前使用的壁纸

2013-12-13 14:40 791 查看
在代码中添加如下方法:

private void updateWallpaperVisibility(boolean visible) {

int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0;

int curflags = getWindow().getAttributes().flags

& WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;

if (wpflags != curflags) {

getWindow().setFlags(wpflags, WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);

}

}

public static boolean forceOpaqueBackground(Context context) {

return WallpaperManager.getInstance(context).getWallpaperInfo() != null;

}

在Activity的onStart()中添上如下代码:

// Hide wallpaper if it's not a static image

if (forceOpaqueBackground(this)) {

updateWallpaperVisibility(false);

} else {

updateWallpaperVisibility(true);

}

将Activity的theme设置为

android:theme="@android:style/Theme.Translucent"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐