【发布时间】:2014-10-06 15:55:00
【问题描述】:
我的布局如下:
Framelayout 和两个 ImageViews。每个ImageView 有一张图片。
我想要实现的是:在ImageView 上触摸时,触摸区域应变为透明并显示下图。
布局 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/rect" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/i2" />
</FrameLayout>
</LinearLayout>
所以基本上在imageView2 上触摸时,触摸区域应该显示来自imageView1 的图像。
我只需要一些指针或引用。
【问题讨论】:
-
我认为您必须根据触摸位置手动更改图像的 Alpha 级别。
-
@mata 有什么参考例子吗?
-
@mata 我做了一个很好的解决方案,但在那个例子中,答案是使用 onDraw 动态绘制图像,而我有一个带有图像视图的 xml 布局,我想在其中应用效果
-
解决了,刚刚了解了自定义视图,实现了链接中的代码@mata 发布在自定义视图中,然后在我的布局中使用了该自定义视图,干杯
标签: android image-processing android-imageview android-image