【问题标题】:How to shrink/decrease the hit area of a button in android?如何缩小/减少android中按钮的点击区域?
【发布时间】:2016-08-26 01:35:31
【问题描述】:

我已经尝试过 TouchDelegate,据说可以做到这一点。它可以增加命中区域,但不能减少命中区域。

我们可以只在 xml 文件中更改点击区域吗?

我的测试代码是从Extend a Child View's Touchable Area复制过来的,里面写着“如果需要,你也可以使用这种方法来缩小孩子的触摸区域。”。

【问题讨论】:

  • 我尝试使用delegateArea.right -= 100; delegateArea.bottom -= 100;

标签: java android user-interface view touch


【解决方案1】:

在您提供的链接中:

 // Extend the touch area of the ImageButton beyond its bounds  
 // on the right and bottom.  
 delegateArea.right += 100;  
 delegateArea.bottom += 100;

改成:

 delegateArea.right -= 100;  
 delegateArea.bottom -= 100;

现在您将获得所需的结果。您可能希望将值从 100 更改为您认为合适的值。

【讨论】:

  • 我这样做了,但没有工作!我点击边缘,按钮仍然被点击。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-06-10
  • 1970-01-01
  • 1970-01-01
  • 2021-06-04
  • 1970-01-01
  • 1970-01-01
  • 2021-10-01
相关资源
最近更新 更多