title: Android set wallpaper of home screen with centering the image
body: <p>I wrote a simple application that sets the wallpaper on the device. I can't achieve one effect. I wish the picture automatically centrated horizontally. This means that the center of the image was on the most central desktop of Luncher app.
  The picture at the bottom shows how it looks now:
  <img src="https://i.stack.imgur.com/w0qoG.png" alt="enter image description here"></p>
  
  <p>Effect that I want to achieve:</p>
  
  <p><img src="https://i.stack.imgur.com/2Il4P.png" alt="enter image description here"></p>
  
  <p>And the image itself:</p>
  
  <p><img src="https://i.stack.imgur.com/vV3d9.jpg" alt="enter image description here"></p>
  
  <p>I tried to use the code from <a href="https://stackoverflow.com/questions/18499133/center-android-wallpaper">this question</a>, however, did not achieve the desired effect.</p>
  
  <p>My code:</p>
  
  <pre><code>public class SystemWallpaperHelper {
  private Context context;
  private ImageLoader imageLoader;
  private DisplayImageOptions imageLoaderOptions;
  
  public SystemWallpaperHelper(Context context){
      this.context = context;
      setImageLoaderOptions();
  }
  
  private void setImageLoaderOptions() {
      final int width = SharedHelper.getDeviceWidth(context) &lt;&lt; 1 ; // best wallpaper width is twice screen width
      imageLoaderOptions = new DisplayImageOptions.Builder()
              .imageScaleType(ImageScaleType.NONE)
              .cacheInMemory(false)
              .cacheOnDisk(false)
              .postProcessor(new BitmapProcessor() {
                  @Override
                  public Bitmap process(Bitmap bmp) {
                      float scale =  (float) width / bmp.getWidth() ;
                      int height = (int) (scale * bmp.getHeight());
                      return Bitmap.createScaledBitmap(bmp, width, height, false);
                  }
              })
              .build();
      imageLoader = ImageLoader.getInstance();
  }
  
  public void setDeviceWallpaper(Wallpaper wallpaper){
      imageLoader.loadImage(wallpaper.getSrcUrl(), imageLoaderOptions, new SimpleImageLoadingListener(){
          @Override
          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage)
          {
              WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
              try {
                  wallpaperManager.setBitmap(loadedImage);
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      });
  }
  }
  </code></pre>