在图像中,您可以显示一个固定的框架。我想裁剪仅显示在框架透明区域的图像部分。那么如何找到框架的透明区域呢?以及如何只让后面的图像只显示在透明区域...?
最佳答案
这里只是我们在相对布局之间获取两个 ImageView 。第一帧(快照中的 ImageView 上方)是固定的,在按钮点击监听器上是我们在框架后面调整的第二张图像,这里有一个简单的逻辑。并不复杂。
但主要的是我们想要框架的透明区域。这里的框架不像上面的截图那样,但无论如何,比如脸或手等等,我预先声明所以裁剪它(框架透明部分)并将它放在另一个图像中。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browse gallery" >
</Button>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/Button01"
>
</ImageView>
<ImageView
android:id="@+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/Button01"
android:background="@drawable/frame" >
</ImageView>
关于android - 如何裁剪只在透明区域显示的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11131880/