Skip to content Skip to sidebar Skip to footer

How To Set The Background Screen As Wallpaper All The Time?

Currently, I'm using this to show my application background as phone wallpaper. getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER, WindowMana

Solution 1:

For users of AppCompat, just use the following in your styles.xml, no need for code:

<!-- Base application theme. --><stylename="AppTheme"parent="Theme.AppCompat"><itemname="android:windowBackground">@android:color/transparent</item><itemname="android:colorBackgroundCacheHint">@null</item><itemname="android:windowShowWallpaper">true</item><itemname="android:windowTranslucentNavigation">true</item><itemname="android:windowTranslucentStatus">true</item></style>

Solution 2:

After long search and trial and error. I've found the solution to what I wanted. It was just creating separate themes.xml file and just tweak the Theme.Dialog which is already defined in default android themes.xml. All I did was change the Animation part. Originally in android themes.xml the line looks like this.

<itemname="android:windowAnimationStyle">@android:style/Animation.Dialog</item>

but since modifying in android themes.xml doesn't take the effect. I just created my own themes.xml as I said above and just set parent as android:Theme.Dialog. And added a line like this.

<item name="android:windowAnimationStyle">@android:style/Animation</item>

Thanks for the help and I hope this solution helps others.

Solution 3:

Use following code -

    rl = (RelativeLayout)findViewById(R.id.someid);
    //relative layout is my root node in main.xml (yours may be linearlayout)WallpaperManagerwm= WallpaperManager.getInstance(this);
    Drawabled= wm.peekDrawable();
    rl.setBackgroundDrawable(d);// You can also use rl.setBackgroundDrawable(getWallpaper);

Post a Comment for "How To Set The Background Screen As Wallpaper All The Time?"