可点击区域的图像视图中?视图、图像、区域

2023-09-07 11:12:11 作者:圈子不同别硬碰

我想就这个形象可以点击各个区域。我已经切割图像到它的不同选择,然后把它与一个相对布局一起然后用于每个区域的onclick。这工作但是在图像周围的透明区域也算作可点击区域。这使得一些地区的硬/无法点击。

I'm trying to make each area on this image clickable. I have cutting the image into its different selections and then put it together with a relative layout then used a onclick for each area. This works however the transparent area around the images count as the clickable area too. This makes some area's hard/impossible to click on.

下面是图片: https://m.xsw88.com/allimgs/daicuo/20230907/5229.png

有没有什么办法让onlclick忽略透明区域的或者这只是不去上班?

Is there any way to make the onlclick ignore the transparent area's or is this just not going to work?

推荐答案

//你可以使用onTouch听者

// you can use onTouch Listner

myimageView.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {

   Log.e("HIGHT CLICk!!"+ event.getY(), "-----------"+event.getX());

    if((26<event.getX() && event.getX()<120) && (25<event.getY()&&event.getY()<120)){

//do your actions here
}