using WalpaperManager
requires storage permition
. so I suggest this amazing way:
if your main theme name is AppTheme
, some thing like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
then create another theme named AppTheme.Wallpaper
:
<style name="AppTheme.Wallpaper" parent="AppTheme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
then put that theme in the manifest as your activity attribute:
<activity android:name=".YOUR_ACTIVITY"
android:theme="@style/AppTheme.Wallpaper">
</activity>