如何降低onTouch的灵敏度?

时间:2018-01-16 05:44:09

标签: android android-event android-gesture android-touch-event

如何降低onTouch的灵敏度?我有一个带有虚拟触摸板的自定义遥控器。问题是当我将手指移到触摸板上时,鼠标光标移动得非常快。那么有没有办法降低移动速度?

我已经搜索了这个问题,并且在一些文章中写道,只有在手机扎根的情况下才有可能。

public void onTouch(View v, MotionEvent event) {
    KeyImageView mKeyImageView= (KeyImageView)v;
    int width = mKeyImageView.getWidth();
    int height = mKeyImageView.getHeight();
    Log.d(TAG,"onTouch:"+width+" "+height+" "+RemoteIME.mService.getWidth()+" "+RemoteIME.mService.getHeigt());
    int touch_x = switchTouchXY((int)event.getX(), width, RemoteIME.mService.getWidth());
    int touch_y = switchTouchXY((int)event.getY(), height, RemoteIME.mService.getHeigt());
    Touch mTouch = new Touch(RemoteIME.mService, event.getAction(), touch_x, touch_y);
    sendCmdMessage(SendThread.CMD_SEND_TOUCH, 0, 0, mTouch);
}

public int switchTouchXY(int touch, int source, int target) {
    return (touch * target / source);
}

0 个答案:

没有答案