Android自定义形状图像裁剪

问题描述 投票:1回答:1

我想以不同的形状裁剪图像,为此我编写了如下的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

所以如何使图像进入定义的形状。

我想以不同的形状裁剪图像,为此我编写了如下的XML代码。 <...>[

android crop
1个回答
0
投票

您可以使用此function

© www.soinside.com 2019 - 2024. All rights reserved.