裁剪和缩放图像而不移动叠加视图而是在 ImageView 中移动图像

Raj*_*Raj 5 android crop imageview android-imageview

嗨,我想在不移动叠加视图的情况下裁剪图像而不是移动图像。 在此处输入图片说明

图像可以四处移动。我想裁剪并保存突出显示的区域,如下所示在黑色边框内。

我有ImageViewandroid:scaleType="matrix"

这是我的布局代码

<RelativeLayout
    android:id="@+imageEdit/rl_ScaleImage"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+imageEdit/Topbar"
    android:visibility="visible" >

    <ImageView
        android:id="@+imageEdit/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:scaleType="matrix" />

    <View
        android:id="@+imageEdit/viewTop"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:background="#99000000" />

    <View
        android:id="@+imageEdit/view_scaledImage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+imageEdit/viewBottom"
        android:layout_below="@+imageEdit/viewTop"
        android:background="@drawable/rounded_corner_small" />

    <View
        android:id="@+imageEdit/viewBottom"
        android:layout_width="fill_parent"
        android:layout_height="150dp"
        android:layout_alignParentBottom="true"
        android:background="#99000000" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

ImageViewOnTouchListener. 图像可以放大或缩小,也可以移动ImageView1。Viewview_scaledImage是我想要裁剪和保存的区域。我该怎么做呢?

Ram*_*ula 4

最后我通过结合 Cropper 库和 PhotoView 库得到了解决方案。

https://github.com/rameshkec85/AndroidCropMoveScaleImage