Reputation: 1
How can I set a wallpaper which looks good for both Landscape and Portrait mode? The code I am using set the live wallpaper only in One mode either in portrait or landscape. Suppose if I set the wallpaper in Portrait mode and go to home screen and change the orientation to Landscape, the wallpaper is fitting only half of the screen in Landscape mode and the other half is showing blank screen. Please help me in this.
WallpaperManager wallpaperManager =WallpaperManager.getInstance(getBaseContext());
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
Bitmap wallpaper = Bitmap.createScaledBitmap(bitmap1,width,height, true);
Canvas canvas = new Canvas(wallpaper);
imageView.draw(canvas);
textView.draw(canvas);
try {
wallpaperManager.setBitmap(wallpaper);
wallpaperManager.suggestDesiredDimensions(width,height);
}
catch (IOException e) {
Toast.makeText(FullImageActivity.this,
"Error setting wallpaper", Toast.LENGTH_SHORT)
.show();
}
Upvotes: 0
Views: 1601
Reputation: 2482
I think you only use static wallpaper service (Not live wallpaper). This can work different on different devices. The main conception is that it uses square images, which wide as the longer screen aspect. It crops the center of the image in most cases, but can be overdefined by manufacturers as I experienced. This helped me to work out a better way: https://github.com/kghost/android-static-live-wallpaper
Upvotes: 0