【问题标题】:Android: How to avoid presses outside the circle of a round button using wrap content?Android:如何避免使用包装内容在圆形按钮的圆圈外按下?
【发布时间】:2012-11-19 10:00:12
【问题描述】:

谁能告诉我如何避免按下圆形按钮的圆圈,因为“wrap_content”似乎不起作用。我使用图像文件来创建按钮。我很感激任何帮助。谢谢。

【问题讨论】:

标签: android eclipse android-layout imagebutton


【解决方案1】:

仅供您理解..(默认情况下,android View 为矩形,因此它适用于 Button)

  1. Touch Listener 设置为您的按钮,并在 onTouch() 中为圆形区域映射 X-Y 坐标。 如果它位于内部区域,请执行您想要的操作,否则返回 false

  2. 使用Inset看这个教程http://www.anotherandroidblog.com/2011/07/01/button-hit-area-for-custom-graphics/

  3. 实现TouchDelegates看这个教程http://www.vogella.com/blog/2012/04/15/android-using-touchdelegates/

【讨论】:

    猜你喜欢
    • 2012-02-21
    • 1970-01-01
    • 2021-10-04
    • 2015-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 2014-07-13
    相关资源
    最近更新 更多