WebView getScale - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WebView getScale method.

This code example shows how to use the following methods:getLocationOnScreen, getScale
	} 
	 
	public static Map<String, Object> translateRectToScreenCoordinates(WebView webView, Map<String, Object> rectangle) {
		try { 
			 
            float scale = webView.getScale();
 
			int[] webviewLocation = new int[2];
			webView.getLocationOnScreen(webviewLocation);
			//center_x, center_y 
			//left, top, width, height 
			float center_x = translateCoordToScreen(webviewLocation[0], scale,
					rectangle.get("center_x"));
			float center_y = translateCoordToScreen(webviewLocation[1], scale,
					rectangle.get("center_y"));
									 
			float x = translateCoordToScreen(webviewLocation[0], scale, rectangle.get("left"));
			float y = translateCoordToScreen(webviewLocation[0], scale, rectangle.get("top"));
			Map<String,Object> result = new HashMap<String, Object>(rectangle);
			 
7
CodeRank
This code example shows how to use the following methods:getScrollX, getScrollY, getScale
    public void clearTouchMetaState() { 
        mTouchMetaState = 0;
    } 
 
    private int contentsToWindowX(int x) {
        return Math.round(x * mWebView.getScale()) - mWebView.getScrollX();
    } 
 
    private int contentsToWindowY(int y) {
        return Math.round(y * mWebView.getScale()) - mWebView.getScrollY();
    } 
 
    private WebView mWebView = null;
    private int mouseX;
    private int mouseY;
 
    private class TouchPoint { 
        private int mId;
        private int mX;
        private int mY;
6
CodeRank
This code example shows how to use the following methods:getScrollX, getScrollY, getScale
            return mY;
        } 
    } 
 
    private Point createViewPointFromContentCoordinates(int x, int y) {
        return new Point(Math.round(x * mWebView.getScale()) - mWebView.getScrollX(),
                         Math.round(y * mWebView.getScale()) - mWebView.getScrollY());
    } 
 
    public static class TouchPoint { 
        private int mId;
        private Point mPoint;
        private long mDownTime;
        private boolean mReleased = false;
        private boolean mMoved = false;
        private boolean mCancelled = false;
 
        public TouchPoint(int id, Point point) {
            mId = id;
            mPoint = point;
7
CodeRank
This code example shows how to use the following methods:setHorizontalScrollBarEnabled, setVerticalScrollBarEnabled, getScale, getSettings, setBackgroundColor
6
CodeRank
This code example shows how to use the following methods:getScrollX, getScrollY, getScale
            return mY;
        } 
    } 
 
    private Point createViewPointFromContentCoordinates(int x, int y) {
        return new Point(Math.round(x * mWebView.getScale()) - mWebView.getScrollX(),
                         Math.round(y * mWebView.getScale()) - mWebView.getScrollY());
    } 
 
    public static class TouchPoint { 
        private int mId;
        private Point mPoint;
        private long mDownTime;
        private boolean mReleased = false;
        private boolean mMoved = false;
        private boolean mCancelled = false;
 
        public TouchPoint(int id, Point point) {
            mId = id;
            mPoint = point;
5
CodeRank
This code example shows how to use the following methods:getScale
	public View(WebView view) {
		this.view = view;
	} 
 
	public final float getScale() { 
		return view.getScale();
	} 
 
	public final void reload() { 
		view.reload();
	} 
 
	public final void setBackgroundColor(int color) {
		view.setBackgroundColor(color);
	} 
 
	public final void loadFile(String path) {
		view.loadUrl("file:///android_asset/" + path);
	} 
	 
4
CodeRank
This code example shows how to use the following methods:requestFocus, setFocusable, setFocusableInTouchMode, setOnFocusChangeListener, addJavascriptInterface
  public static WebView create(final AndroidWebDriver driver) {
 
    WebChromeClient chromeClient = new ChromeClient(driver);
    WebViewClient viewClient = new ViewClient(driver);
 
    WebView view = new WebView(driver.getActivity());
    view.setWebChromeClient(chromeClient);
    view.setWebViewClient(viewClient);
 
    final float zoom = view.getScale();
 
    view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
      public void onFocusChange(View view, boolean focused) {
        // When a text area is focused, webview's focus is false 
        if (!focused) {
          driver.setEditAreaHasFocus(true);
        } 
      } 
    }); 
     

-2
CodeRank
getScale Method Overview
This method was deprecated in API level 17. This method is prone to inaccuracy due to race conditions between the web rendering and UI threads; prefer onScaleChanged(WebView, float, float).
See Code Examples for other Android WebView Methods: