1
  ImageView im1_b;
    im1_b = (ImageView)findViewById(R.id.b_01_b);
    im1_b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            AlertDialog.Builder builder = new AlertDialog.Builder(Next_2Activity.this);
            builder.setTitle("Project Gmelon");
            builder.setMessage("Are you sure set Wallpaper?");
            builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
               Toast.makeText(getApplicationContext(),
                       "You Select NO", Toast.LENGTH_LONG) .show();
                }
            });
            builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    WallpaperManager myWallpaperManager
                    = WallpaperManager.getInstance(getApplicationContext());
                   try {
                    myWallpaperManager.setResource(R.drawable.b_01_i);
                   } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                   }
                    Toast.makeText(getApplicationContext(),
                           "Setting Complete, Thanks.", Toast.LENGTH_LONG) .show();
                }

            });

            builder.show();
        }
    });

I wrote code like this to set wallpaper.. but

my image is setting like this. (http://wemakeucc.com/1.jpg)

and I want like this.. (http://wemakeucc.com/2.JPG)

how can I do..?

EDIT1>

ImageView im1_b;
im1_b = (ImageView)findViewById(R.id.b_01_b);
im1_b.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
im1_b.setOnClickListener(new OnClickListener() {
Alex-Hyun
  • 85
  • 2
  • 3
  • 14

1 Answers1

0

If you want to do it in code you can do this:

YOUR_IMAGE_VIEW.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

You can optionally experiment with other scale types instead of CENTER_INSIDE if you like!

If you want to do it in xml, set the scaleType property with you desired scale type:

android:scaleType="centerInside"

Check this link for scale types: Scale Types

Koded101
  • 375
  • 4
  • 11
  • is you wallpaper set on im1_b? – Koded101 Feb 17 '13 at 14:15
  • Haha.. i can't do it now..so i test it later and comment here.. THANKS – Alex-Hyun Feb 17 '13 at 14:21
  • Looks like you are trying to set the system wallpaper. Unfortunately you can't use setScaleType on the WallpaperManager object. Not sure if you can get the view/imageview which the wallpaper is displayed on and setScaleType on that? – Koded101 Feb 18 '13 at 10:14
  • Then there are any solutions to use setscaletype? – Alex-Hyun Feb 18 '13 at 12:44
  • I'm afraid I can't help much in this area. Your problem is most likely due to androids wallpaper requirements (http://lifehacker.com/5657727/whats-the-deal-with-androids-weird-wallpaper-requirements) – Koded101 Feb 18 '13 at 19:06