Add a WebView.zoomBy API.

The WebView has zoomIn/zoomOut APIs which zoom in/out by a fixed
amount. This adds a more flexible API.

BUG: 13399510
Change-Id: Ia505048d5b1c48f9a3ff1c4ce7129ed2f55804f8
This commit is contained in:
Marcin Kosiba
2014-07-15 17:59:51 +01:00
parent d1d2d43fc0
commit 3ee06efef3
3 changed files with 20 additions and 0 deletions

View File

@@ -36700,6 +36700,7 @@ package android.webkit {
method public void setWebViewClient(android.webkit.WebViewClient);
method public deprecated boolean showFindDialog(java.lang.String, boolean);
method public void stopLoading();
method public boolean zoomBy(float);
method public boolean zoomIn();
method public boolean zoomOut();
field public static final java.lang.String SCHEME_GEO = "geo:0,0?q=";

View File

@@ -1944,6 +1944,23 @@ public class WebView extends AbsoluteLayout
return mProvider.canZoomOut();
}
/**
* Performs a zoom operation in this WebView.
*
* @param zoomFactor the zoom factor to apply. The zoom factor will be clamped to the Webview's
* zoom limits. This value must be in the range 0.01 to 100.0 inclusive.
*
* @return false if no zoom changes, true otherwise.
*/
public boolean zoomBy(float zoomFactor) {
checkThread();
if (zoomFactor < 0.01)
throw new IllegalArgumentException("zoomFactor must be greater than 0.01.");
if (zoomFactor > 100.0)
throw new IllegalArgumentException("zoomFactor must be less than 100.");
return mProvider.zoomBy(zoomFactor);
}
/**
* Performs zoom in in this WebView.
*

View File

@@ -238,6 +238,8 @@ public interface WebViewProvider {
public boolean canZoomOut();
public boolean zoomBy(float zoomFactor);
public boolean zoomIn();
public boolean zoomOut();