2021年1月3日星期日

How can I align my image to center while setting image as wallpaper

I am using Firebase. How can I align my image to center while setting image as wallpaper. Below is my Code:

imgholder = view.findViewById(R.id.imgholder);  Picasso.get().load(url).fit().centerCrop().into(imgholder);     public static Bitmap viewToBitmap(View view,int width,int height){          Bitmap bm=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);          Canvas canvas=new Canvas(bm);          view.draw(canvas);          return bm;      }    private void setWallpaper() {           WallpaperManager wallpaperManager=WallpaperManager.getInstance(getContext().getApplicationContext());          try {              if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {                  wallpaperManager.setBitmap(viewToBitmap(imgholder,imgholder.getWidth(),imgholder.getHeight()),null,true, WallpaperManager.FLAG_SYSTEM);              }              Toast.makeText(getContext(),"Wallpaper Set Successfully",Toast.LENGTH_SHORT).show();          } catch (IOException e) {              e.printStackTrace();          }      }  
https://stackoverflow.com/questions/65556500/how-can-i-align-my-image-to-center-while-setting-image-as-wallpaper January 04, 2021 at 08:55AM

没有评论:

发表评论