2012-10-08 212 views
-3

我的android應用程序中有一個Imageview。我想移動和規模的形象。我也想裁剪圖像的選定部分(就像照片/圖像編輯器)。我怎樣才能做到這一點?如何移動和縮放圖像

由於提前

+0

是否可以裁剪使用該圖像的選定部分? –

+1

你所有的問題都已經有了答案:[移動圖像] [1],[縮放圖片] [2]和[剪切圖像] [3] [1]:http://stackoverflow.com/問題/ 8696025 /如何在Android上移動圖像 - 屏幕上的圖像 [2]:http://stackoverflow.com/questions/2521959/how-to-scale-an-image -in-imageview-keep-the-aspect-ratio [3]:http://stackoverflow.com/questions/3725501/how-to-crop-the-parsed-image-in-android – slezadav

回答

1

做這樣的事情:

Intent intent = new Intent("com.android.camera.action.CROP"); 
// this will open all images in the Galery 
intent.setDataAndType(photoUri, "image/*"); 
intent.putExtra("crop", "true"); 
// this defines the aspect ration 
intent.putExtra("aspectX", aspectY); 
intent.putExtra("aspectY", aspectX); 
// this defines the output bitmap size 
intent.putExtra("outputX", sizeX); 
intent.putExtra("outputY", xizeY); 
// true to return a Bitmap, false to directly save the cropped iamge 
intent.putExtra("return-data", false); 
//save output image in uri 
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); 
-2
<ImageView 
     android:id="@+id/imgProfilePic" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/image" 
     android:scaleType="fitCenter" <!-- TO CROP/SCALE --> 
android:gravity="center" <!-- TO MOVE --> 
     /> 

希望這可以幫助你