如何设置一个可点击的区域为ImageView的? [英] How to set a clickable region for an ImageView?

查看:223
本文介绍了如何设置一个可点击的区域为ImageView的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2 ImageViews具有AnimationDrawable背景动画的盒子打开和关闭,当你点击它。 2图像略微重叠(透明区域),这样他们可以更加紧密。

I have 2 ImageViews which have AnimationDrawable backgrounds to animate a box opening and closing when you click on it. The 2 images are slightly overlapping (the transparent area) so they can be closer together.

这是造成的问题是,我无法一号图像区域点击其中第二图像(透明区域)是重叠的。

The problem this is causing is that I am unable to click on regions of the 1st image where the 2nd image (transparent area) is overlapping.

有没有办法来设置的ImageView的可点击区域?

Is there a way to set a clickable region of an ImageView?

推荐答案

我不认为你可以像你会在HTML做一个图上的ImageView的定义可点击区域。 IMO你能做的最好是借鉴你的的ImageView 具有相同的大小,并给它一个的onClick 方法。现在,我不知道的一切,所以也许我错了。

I don't think that you can "define a clickable region on an ImageView" like you would do in HTML with a map. IMO the best you could do is draw a canvas on top of your ImageView with the same size, and give it an onClick method. Now, I don't know everything, so maybe I'm mistaken.

这篇关于如何设置一个可点击的区域为ImageView的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆