Android自定义形状图像裁剪

时间:2018-06-04 08:57:11

标签: android crop

我想裁剪不同形状的图像,为此我编写XML代码,如下所示。

<?xml version="1.0" encoding="utf-8"?>               

<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent">

      <RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/relative">

          <ImageView
                 android:layout_width="match_parent"
                 android:layout_height="450dp"
                 android:id="@+id/original"
                 android:src="@drawable/image1"/>


          <ImageView
                 android:layout_width="match_parent"
                 android:layout_height="450dp"
                 android:id="@+id/frame"
                 android:scaleType="matrix"
                 android:src="@drawable/f1" />

     </RelativeLayout>

       <Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/btnblur"
          android:layout_marginTop="450dp"
          android:text="Crop"/>

</RelativeLayout>

,布局如下所示output of this layout

在按钮点击方法中,我编写了如下代码

位图输出= getBitmapOfView(frame_img); [此处frame_img是包含形状的视图]

但我得到了输出 output on button click

所以如何在定义的形状内获取图像。

0 个答案:

没有答案