List of usage examples for android.webkit WebSettings setSupportZoom
public abstract void setSupportZoom(boolean support);
From source file:com.tct.mail.ui.ConversationViewFragment.java
private void setupOverviewMode() { // for now, overview mode means use the built-in WebView zoom and disable custom scale // gesture handling final boolean overviewMode = isOverviewMode(mAccount); final WebSettings settings = mWebView.getSettings(); final WebSettings.LayoutAlgorithm layout; // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 DEL_S // settings.setUseWideViewPort(overviewMode); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 DEL_E settings.setSupportZoom(overviewMode); settings.setBuiltInZoomControls(overviewMode); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 DEL_S // settings.setLoadWithOverviewMode(overviewMode); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 DEL_E if (overviewMode) { settings.setDisplayZoomControls(false); layout = WebSettings.LayoutAlgorithm.NORMAL; } else {/* ww w. jav a 2 s . c om*/ layout = WebSettings.LayoutAlgorithm.NARROW_COLUMNS; } settings.setLayoutAlgorithm(layout); }
From source file:android.webkit.cts.WebViewTest.java
public void testZoom() throws Throwable { if (!NullWebViewUtils.isWebViewAvailable()) { return;/*from www. ja v a 2 s. com*/ } // Pinch zoom is not supported in wrap_content layouts. mOnUiThread.setLayoutHeightToMatchParent(); final ScaleChangedWebViewClient webViewClient = new ScaleChangedWebViewClient(); mOnUiThread.setWebViewClient(webViewClient); mWebServer = new CtsTestServer(getActivity()); mOnUiThread.loadUrlAndWaitForCompletion(mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL)); pollingCheckForCanZoomIn(); WebSettings settings = mOnUiThread.getSettings(); settings.setSupportZoom(false); assertFalse(settings.supportZoom()); float currScale = mOnUiThread.getScale(); float previousScale = currScale; // can zoom in or out although zoom support is disabled in web settings assertTrue(mOnUiThread.zoomIn()); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); assertTrue(mOnUiThread.zoomOut()); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); mOnUiThread.zoomBy(1.25f); // zoom in previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); mOnUiThread.zoomBy(0.8f); // zoom out previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); // enable zoom support settings.setSupportZoom(true); assertTrue(settings.supportZoom()); previousScale = mOnUiThread.getScale(); assertTrue(mOnUiThread.zoomIn()); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); // zoom in until it reaches maximum scale while (mOnUiThread.zoomIn()) { previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); } previousScale = currScale; // can not zoom in further assertFalse(mOnUiThread.zoomIn()); // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); assertTrue(mOnUiThread.zoomOut()); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); // zoom out until it reaches minimum scale while (mOnUiThread.zoomOut()) { previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); } previousScale = currScale; assertFalse(mOnUiThread.zoomOut()); // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); mOnUiThread.zoomBy(1.25f); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); // zoom in until it reaches maximum scale while (mOnUiThread.canZoomIn()) { previousScale = currScale; mOnUiThread.zoomBy(1.25f); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); } previousScale = currScale; // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); mOnUiThread.zoomBy(0.8f); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); // zoom out until it reaches minimum scale while (mOnUiThread.canZoomOut()) { previousScale = currScale; mOnUiThread.zoomBy(0.8f); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); } previousScale = currScale; // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); }
From source file:android.webkit.cts.WebViewTest.java
@SuppressWarnings("deprecation") @UiThreadTest/*from ww w. ja v a2 s .c o m*/ public void testGetZoomControls() { if (!NullWebViewUtils.isWebViewAvailable()) { return; } WebSettings settings = mWebView.getSettings(); assertTrue(settings.supportZoom()); View zoomControls = mWebView.getZoomControls(); assertNotNull(zoomControls); // disable zoom support settings.setSupportZoom(false); assertFalse(settings.supportZoom()); assertNull(mWebView.getZoomControls()); }