1

Another wallpaper question, i was setting it using wallpaper manager but i found the wallpaper doesnt scroll, tried different launchers but same thing is happening, after alot of research i found its an android version issue and nobody has answered my other question so i found one answer that gets the screen dimensions and the bitmaps dimensions on android hive then scales the bitmap accordingly.

    bitmapWidth = (bitmapWidth * screenHeight) / bitmapHeight;

THIS WORKS! the image is scrolling but the image is overstrectched so im using this method and playing with screen height and width and bitmap height and width to try and get this to sit nicely what i want is the image to be scaled perfectly on any device and to scroll properly any suggestions?

Community
  • 1
  • 1
Martin Seal
  • 616
  • 2
  • 14
  • 32
  • What is your question? – Machado Jul 22 '15 at 14:55
  • sorry @holmes your right its not clear will edit the question, i want the wallpaper to be scaled correctly and scroll and ive found a solution but please take a look at my other question linked above – Martin Seal Jul 22 '15 at 15:33

1 Answers1

0

so after playing alot with this i found its rather simple after getting the dimensions for screen height, and bitmap height and width and using this

bitmapWidth = (bitmapWidth * screenHeight) / bitmapHeight;

i can pass the new dimension to bitmap height

bitMapHeight = bitmap_Width;

im new so if this is a bad solution please correct me but tried on 2 different phones and 2 different tablets and it works for my case, here is my full method call;

    private void setWallPaper() throws IOException {
    int screenHeight;
    int screenWidth;
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    screenHeight = size.y;
    screenWidth = size.x;
    Bitmap bitmap = ((BitmapDrawable)   
    WallpaperView.getDrawable()).getBitmap();
    int bitmapWidth = bitmap.getWidth();
    int bitmapHeight = bitmap.getHeight();
    bitmapWidth = (bitmapWidth * screenHeight) / bitmapHeight;
    bitmapHeight = bitmapWidth;
    WallpaperManager wallpaperManager = 
    WallpaperManager.getInstance(getActivity());
    wallpaperManager.setBitmap(bitmap.createScaledBitmap
    (bitmap,bitmapWidth,bitmapHeight,true));
        Snackbar.make(getActivity().findViewById(R.id.wallLayout),  
    "Wallpaper Set "+"height"+ bitmapHeight+ "width"+bitmapWidth,  
     Snackbar.LENGTH_LONG)
                .show();
    }
Martin Seal
  • 616
  • 2
  • 14
  • 32