对于我的应用程序我想检测用户何时触摸屏幕的一部分,例如,假设屏幕是800像素高,只有当它接触500像素到800像素时,考虑到高度。有可能吗?
我试过了:
public boolean onTouchEvent(MotionEvent event){
float x_forOnTouch = event.getX();
float y_forOnTouch = event.getY();
}
答案 0 :(得分:1)
这样的事情:
private static final TOP_BORDER = 800;
private static final BOTTOM_BORDER = 500;
public boolean onTouchEvent(MotionEvent event){
float x_forOnTouch = event.getX();
float y_forOnTouch = event.getY();
if (y_forOnTouch > BOTTOM_BORDER && y_forOnTouch < TOP_BORDER){
processTouches(); //do what you want
}
}