0

I use code to set Wallpaper on your desktop:

Button buttonSetWallpaper = (Button)findViewById(R.id.set);
        ImageView imagePreview = (ImageView)findViewById(R.id.preview);
        imagePreview.setImageResource(R.drawable.five);

        buttonSetWallpaper.setOnClickListener(new Button.OnClickListener(){
        @Override
        public void onClick(View arg0) {
        // TODO Auto-generated method stub
        WallpaperManager myWallpaperManager 
        = WallpaperManager.getInstance(getApplicationContext());
        try {
            myWallpaperManager.setResource(R.drawable.five);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        }});

as you can see from the code, for a preview and to install the Wallpapers used the same image (R. drawable.five). Is it possible to programmatically change the size and quality of images for the preview? Or the only way to create another smaller picture and use it as a preview? Also I would be very grateful, if somebody will throw a link to the source install Wallpaper similar to this: http://iscr.ru/1421354369/

GAAAN
  • 399
  • 2
  • 3
  • 14
  • by reduce image size you want to compress the image eg from 250kb to 120 kb or change the width and height of the image? – Ankit Jan 15 '15 at 21:00
  • Yes, I don't want to create a separate image for preview. – GAAAN Jan 15 '15 at 21:04

1 Answers1

0

Well assuming you are trying to change the width and height of the image. Here how you can do it.

 imagePreview.getLayoutParams().height = 20;
 imagePreview.getLayoutParams().width = 30;

If your image view is dynamic use this:

 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(20, 30);
 imagePreview.setLayoutParams(layoutParams);

In case you want to scale your images, please check this answer How to compress images programatically

Community
  • 1
  • 1
Ankit
  • 1,075
  • 1
  • 8
  • 19
  • Thank you! It works! but not solve my problem. The fact that I use an image size of 1920*1080. And even if I visually change the image on your code, the interface of my application very "slow". Maybe you know where to get the source code of the standard Android application to apply Wallpaper. Like this: http://iscr.ru/1421354369/ – GAAAN Jan 15 '15 at 21:20
  • perhaps this might helps you.. http://stackoverflow.com/questions/12346023/creating-simple-wallpaper-application-in-android – Ankit Jan 15 '15 at 21:27