设置应用背景是一样的主屏幕壁纸 [英] Set app background to be the same as home screen wallpaper

查看:242
本文介绍了设置应用背景是一样的主屏幕壁纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置我的应用程序的背景是一样的我的主屏幕的壁纸。我怎样才能在activity.xml主屏幕壁纸?我能做到吗?

I want to set my app's background to be the same as my home screen's wallpaper. How can I get the home screen wallpaper in activity.xml? Can I do that?

推荐答案

使用

final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();

来获得当前的墙纸。然后将其设置为自己的应用程序的背景:

to get the current wallpaper. Then set it as your own app's background:

LinearLayout ll = (LinearLayout) findViewById(R.id.myLinearLayout);//Substitute with your layout
ll.setBackground(wallpaperDrawable); 

这一切都应该在发生的onCreate(),如果你希望拥有它作为初始背景。

All this should happen in the onCreate() if you wish to have it as the initial background.

这篇关于设置应用背景是一样的主屏幕壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆