【问题标题】:How to move and scale an Image [closed]如何移动和缩放图像[关闭]
【发布时间】:2012-10-08 09:44:24
【问题描述】:

我的 android 应用程序中有一个 Imageview。我想移动和缩放图像。我还想裁剪图像的选定部分(就像照片/图像编辑器一样)。我怎样才能做到这一点?

提前致谢

【问题讨论】:

标签: android image


【解决方案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 -->
            />
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2010-10-19
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多