How to shrink Android wallpaper?

125 views Asked by At

Whenever i set a wallpaper, after 1 sec it is zooming and stretching. How to set my image as fit wallpaper? (My image is good enough for wallpaper. 1080*1920).

    DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int height = metrics.heightPixels;
            int width = metrics.widthPixels;
            Bitmap tempbitMap = BitmapFactory.decodeResource(
                    getResources(), R.drawable.a);
            Bitmap bitmap = Bitmap.createScaledBitmap(tempbitMap, width,
                    height, true);
            WallpaperManager wallpaperManager = WallpaperManager
                    .getInstance(MainActivity.this);
            wallpaperManager.setWallpaperOffsetSteps(1, 1);
            wallpaperManager.suggestDesiredDimensions(width, height);
            try {
                wallpaperManager.setBitmap(bitmap);
            } catch (IOException e) {
                e.printStackTrace();
            }`

This problem happens only in original device. For emulator it works fine.

0

There are 0 answers