Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set app background to be the same as home screen wallpaper

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?

like image 983
virho Avatar asked Jul 26 '14 13:07

virho


1 Answers

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.

like image 95
Robin Ellerkmann Avatar answered Oct 30 '22 21:10

Robin Ellerkmann