我有一个位于 View 中的 X 和 Y 坐标的 ArrayList。现在我想检查用户是否触摸了 View ,一些存储的 X 和 Y 坐标是否在触摸点周围的某个半径(如 20 像素)内。我将如何实现?
最好的问候
最佳答案
使用毕达哥拉斯公式。
if(Math.sqrt(Math.pow(stored_x - touched_x, 2) + Math.pow(stored_y - touched_y, 2)) <= 20){
//do thing
}
关于java - 触摸位置周围的半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30401940/