Android programming is a simple implementation of setting the Activity background as a wallpaper

  • 2020-09-16 07:47:45
  • OfStack

This article illustrates a simple implementation of Android programming that sets the Activity background to a wallpaper. To share for your reference, the details are as follows:

1) Code mode


Drawable wallPaper = WallpaperManager.getInstance( this).getDrawable();
this.getWindow().setBackgroundDrawable(wallPaper);

2) XML configuration

In the configuration of the Activity, add:

android:theme = "@android:style/Theme.Wallpaper"

The disadvantage of the first method is that the size of the wallpaper may not match the size of Activity, causing the wallpaper to stretch and require additional treatment

The downside of the second approach is that ActionBar is gone.

I hope this article is helpful for Android programming.


Related articles: