Question

Hi all i want to know how to set background of layout,image view or ... to live wallpaper from java is that possible?how?? pick a live wallpaper and set that for background??we can do it with normal wallpaper with but i don't know about live wallpaper! i tried Google search for long time. i really need to know it.

this is for normal Drawable:

 File backgroundf = new File(Uri.parse("sdcar/Wallpaper_BG.jpg").getPath());
     if (backgroundf !=  null) {
        Bitmap BarbackgroundBitmap = BitmapFactory.decodeFile(backgroundf.getAbsolutePath());
        BackgroundDrawable = new BitmapDrawable(mContext.getResources(), backgroundBitmap);
        }
   mBackground.setImageDrawable(BarBackgroundDrawable);

Thanks.

Was it helpful?

Solution

You can't do this as a drawable or a view background, but you can theme your activity to make the wallpaper or live wallpaper show through.

<style name="MyTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowShowWallpaper">true</item>
</style>

You can use any theme as the parent. Put this in your styles resource and set this theme for the activity in the manifest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top