android.webkit.WebView.getHitRect()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(207)

本文整理了Java中android.webkit.WebView.getHitRect()方法的一些代码示例,展示了WebView.getHitRect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.getHitRect()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:getHitRect

WebView.getHitRect介绍

暂无

代码示例

代码示例来源:origin: GeoODK/collect

public boolean suppressFlingGesture(MotionEvent e1, MotionEvent e2,
    float velocityX, float velocityY) {
  if (mImageDisplay == null
      || mImageDisplay.getVisibility() != View.VISIBLE) {
    return false;
  }
  Rect rect = new Rect();
  mImageDisplay.getHitRect(rect);
  // Log.i(t, "hitRect: " + rect.left + "," + rect.top + " : " +
  // rect.right + "," + rect.bottom );
  // Log.i(t, "e1 Raw, Clean: " + e1.getRawX() + "," + e1.getRawY() +
  // " : " + e1.getX() + "," + e1.getY());
  // Log.i(t, "e2 Raw, Clean: " + e2.getRawX() + "," + e2.getRawY() +
  // " : " + e2.getX() + "," + e2.getY());
  // starts in WebView
  if (rect.contains((int) e1.getRawX(), (int) e1.getRawY())) {
    return true;
  }
  // ends in WebView
  if (rect.contains((int) e2.getRawX(), (int) e2.getRawY())) {
    return true;
  }
  // transits WebView
  if (rect.contains((int) ((e1.getRawX() + e2.getRawX()) / 2.0),
      (int) ((e1.getRawY() + e2.getRawY()) / 2.0))) {
    return true;
  }
  // Log.i(t, "NOT SUPPRESSED");
  return false;
}

代码示例来源:origin: googlesamples/android-PermissionRequest

@Override
  public void run() {
    Rect rect = new Rect();
    webView.getHitRect(rect);
    int x = rect.width() / 2;
    int y = 100;
    MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(),
        SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_DOWN, x, y, 0);
    webView.dispatchTouchEvent(event);
    event = MotionEvent.obtain(SystemClock.uptimeMillis(),
        SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_UP, x, y, 0);
    webView.dispatchTouchEvent(event);
  }
});

相关文章

WebView类方法