【问题标题】:Radius around touched position触摸位置周围的半径
【发布时间】:2015-05-22 16:45:29
【问题描述】:

我有一个位于视图中的 X 和 Y 坐标的 ArrayList。现在我想检查用户是否触摸了视图,如果某些存储的 X 和 Y 坐标在触摸点周围的某个半径(如 20 像素)内。我将如何实现这一点?

最好的问候

【问题讨论】:

    标签: java android math view touch


    【解决方案1】:

    使用毕达哥拉斯公式。

    if(Math.sqrt(Math.pow(stored_x - touched_x, 2) + Math.pow(stored_y - touched_y, 2)) <= 20){
        //do thing
    }
    

    【讨论】:

    • 这正是我想要的
    猜你喜欢
    • 1970-01-01
    • 2017-01-16
    • 2016-12-21
    • 2021-10-27
    • 2016-01-07
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    相关资源
    最近更新 更多