Hi i am coding to set a Home Screen Wallpaper. It's working fine. But my image pixel is totally damaged and then my wallpaper is not fit with the actual size of the home screen. I am try to workout different size of images. Unfortunately it's not working for me. How to solve it.
My code is here
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable drawable = getResources().getDrawable(R.drawable.newimage);
Bitmap wallpaper = ((BitmapDrawable) drawable).getBitmap();
try
{
wallpaperManager.setBitmap(wallpaper);
}
catch (IOException e)
{
e.printStackTrace();
}
My Screenshot Original Image
My Screenshot Android Emulator Home Screen
Why my original image is damaged here.
How to display My Original Image
based on the Emulator Size
.
This is to make the zoom out effect possible on the wallpaper when you open the notification tray (swipe down from the top of the screen).
1 Solution. Go to dynamic lock screen settings and turn off auto update.
With a custom launcher installed, tap Settings > Select Default Launcher or similar to reset back to your original home screen. Remove apps and widgets by holding your finger to them and tapping Uninstall or Remove. Reset your wallpaper by holding a finger to the home screen and tapping Wallpaper.
You can try this:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable drawable = getResources().getDrawable(R.drawable.newimage);
Bitmap wallpaper_source = ((BitmapDrawable) drawable).getBitmap();
try {
int w = wallpaperManager.getDesiredMinimumWidth();
int h = wallpaperManager.getDesiredMinimumHeight();
int x = (w-wallpaper_source.getWidth())/2;
int y = (h-wallpaper_source.getHeight())/2;
Bitmap wallpaper = Bitmap.createBitmap(w, h, Config.ARGB_8888);
Canvas c = new Canvas(wallpaper);
c.drawBitmap(wallpaper_source, x,y, null);
wallpaperManager.setBitmap(wallpaper);
}
catch (IOException e)
{
e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With