设置当前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"
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"
相关文章推荐
- 设置当前Activity背景是当前使用的壁纸
- 设置Activity使用系统壁纸作为背景
- android 使用壁纸作为当前Activity的背景
- C#获取当前电脑桌面的壁纸,并设置成窗体背景图
- 设置当前Activity的背景颜色
- 【起航计划 016】2015 起航计划 Android APIDemo的魔鬼步伐 15 App->Activity->Wallpaper 系统壁纸作为当前Activity的背景
- 【起航计划 016】2015 起航计划 Android APIDemo的魔鬼步伐 15 App->Activity->Wallpaper 系统壁纸作为当前Activity的背景
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet)good
- 【Android 界面效果20】Android GradientDrawable类的详解,设置activity的背景颜色渐变效果
- 关于 QWidget无法使用stylesheet设置自身backgound-color(背景色)和border-image(背景图片) 的解决方法
- 使用命令xrandr设置当前系统的显示分辨率及显示的旋转脚本
- Android 代码设置Activity 背景透明
- 富文本的使用之二 设置TextView不同字段的颜色和背景颜色
- Windows 服务器使用FTP出现“当前的安全设置不允许从该位置下载文件" 警告
- UITableViewCell中使用nib布局设置一个UILabel的背景颜色,出现色差
- 如何使用CSS设置<input>标签的背景小图标 简单
- 使用CSS给空元素设置背景图片
- Qt 设置对话框背景(使用调色板,设置它的画刷,画刷可以是图片)
- 当前ViewGroup背景设置系统背景并增加颜色滤镜效果
- Android设置Activity背景为透明style