2013-02-17 123 views
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(); 
     } 
    }); 

我寫了這樣的代碼來設置壁紙..但設置背景圖片的代碼

我的形象被設定這樣的。 (http://wemakeucc.com/1.jpg

,我想這樣的.. (http://wemakeucc.com/2.JPG

我該怎麼辦......?

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() { 

回答

0

如果你想這樣做的代碼,你可以這樣做:

YOUR_IMAGE_VIEW.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 

,如果你願意的話,可以有選擇地實驗與其他規模類型而不是CENTER_INSIDE!

如果你想這樣做在XML中,設置scaleType屬性與你所期望的規模類型:

android:scaleType="centerInside" 

檢查此鏈接爲規模類型:Scale Types

+0

是相同的..沒有的就是變化.. – KRJ 2013-02-17 14:12:37

+0

我是這樣寫的,但沒有任何變化。 (看我的編輯1>) – KRJ 2013-02-17 14:13:20

+0

是你在im1_b上設置的壁紙嗎? – Koded101 2013-02-17 14:15:28