如何通过调度进行放大或缩小事件?

时间:2019-10-25 15:44:23

标签: android android-webview

我正在尝试使用dispatchTouchEvent()进行放大或缩小事件。 但这根本没有用。 在下面可以看到我的代码,请告诉我该怎么办?还是有其他方法可以在视图上进行放大事件?

public void make_Touch(String msg) {
        long time = SystemClock.uptimeMillis();

    webView.dispatchTouchEvent(MotionEvent.obtain(time,
            time+100,
            MotionEvent.ACTION_DOWN,
            300,
            300,
            0));

    webView.dispatchTouchEvent(MotionEvent.obtain(time,
            time+2000,
            MotionEvent.ACTION_POINTER_DOWN,
            200,
            200,
            0));
    webView.dispatchTouchEvent(MotionEvent.obtain(time+100,
            time+2000,
            MotionEvent.ACTION_MOVE,
            900,
            900,
            0));
    //
    webView.dispatchTouchEvent(MotionEvent.obtain(time+2000,
            time+2100,
            MotionEvent.ACTION_UP,
            900,
            900,
            0));
    webView.dispatchTouchEvent(MotionEvent.obtain(time+2000,
            time+2100,
            MotionEvent.ACTION_POINTER_UP,
            200,
            200,
            0));
    return;
}

0 个答案:

没有答案