如何扩展按钮触摸区域? [英] How to extend a button touch area?

查看:87
本文介绍了如何扩展按钮触摸区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个箭头按钮,希望保持较小,但我希望它周围的触摸区域更大.

I have an arrow button that I want to keep small but I want the touch area around it to be bigger.

我使用了帖子此处的答案,但是它使我的按钮变大了.

I used the answer from the post Here but it made my button larger.

问题在于按钮的图片大于其显示的尺寸.但是我认为必须有一种无需编辑或添加透明按钮的方法.

The problem is that the picture of the button is larger than the size it is presented in. But I thought there must be a way to do it without editing it or adding a transparent button.

推荐答案

您应该可以通过扩展按钮类并覆盖

You should be able to do it by extending the button class and overriding the hitTest method. In your version of this method you can expand the area checked to include a buffer area and return the button if the touch happens within it.

这篇关于如何扩展按钮触摸区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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