Wallpaper not properly fit on device screen

后端 未结 5 511
我寻月下人不归
我寻月下人不归 2020-11-29 08:07

I have one set of images in one drawable folder. I have one button to set image as wallpaper on device screen. But when I set this image as wallpaper its either zoom or crop

5条回答
  •  抹茶落季
    2020-11-29 08:18

    If you have image URL then use :

    WallpaperManager wpm = WallpaperManager.getInstance(context);
    InputStream ins = new URL("absolute/path/of/image").openStream();
    wpm.setStream(ins);
    

    If you have image URI then use

    WallpaperManager wpm = WallpaperManager.getInstance(context);
    wpm.setResource(Uri.of.image);
    

    In your manifest file:

    
    

    and don't forget to place this code in AsyncTask.

提交回复
热议问题