android - 如何在android中创建一个可点击的不规则形状区域?

标签 android android-layout android-custom-view shapes android-vectordrawable

我想在无法填充矩形空间的透明云图像下显示可点击图像。 enter image description here

当使用ImageView并单击对象(吹塑图像)时,单击云。

最好的方法是什么?

最佳答案

采用RelativeLayout并按Z顺序堆叠图像,将最前面的图像保留为RelativeLayout的最后一个元素。

然后你可以做的是获取所有图像的 onClickListener 并在云图像中不执行任何操作,并将 onClick 的正文保留为空。

虽然您可以为要执行操作的图像提供适当的 onClick。

希望这有帮助

 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    //hidden Image
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    //Frontmost image
    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        />

</RelativeLayout>

关于android - 如何在android中创建一个可点击的不规则形状区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44465736/

相关文章:

android - ldpi、mdpi、hdpi 和 xhdpi 屏幕的背景尺寸应该是多少?

java - TabLayout setText() 和 setIcon() 无法与自定义 View 一起正常工作

android - 如何为您的 Adapter 选择最佳构造函数?

android - robospice 中的 json 读取错误

android - 您上传的 APK 未使用上传证书签名 - 即使我使用的是 Google Play 签名

android - 来自 GoogleAuthUtil 的 "Calling this from your main thread can lead to deadlock and/or ANRs while getting accesToken"(Android 中的 Google Plus 集成)

android - 如何使用菜单选项从另一个 Activity 格式化一个 Activity

android - 如何在我的 Android 应用程序中实现这样的布局?

android - 当文本未完全在 View 内绘制时,为什么 Canvas.drawText 会变慢?

android - 自定义 EditText - Material 设计