Set app background to be the same as home screen wallpaper

virho picture virho · Jul 26, 2014 · Viewed 9.5k times · Source

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?

Answer

Robin Ellerkmann picture Robin Ellerkmann · Jul 26, 2014

Use

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); 

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