Is it possible to remove the zoom buttons ? Its showing when I zooming the WebView. I need zoom control without these buttons. I'm using android 2.3.
I used below code,
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setBuiltInZoomControls(false);
webview.getSettings().setJavaScriptEnabled(true);
FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = webview.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.GONE);
In Android, Zoom Control is a class that has some set of methods that are used to control the zoom functionality. It has two buttons that are used to control the zoom functionality (ie Zoom In and Zoom Out). Zoom Control Class has been deprecated in API Version 29.
getSettings().setBuiltInZoomControls(false);
use the above line of code to remove the zoom buttons.
On API >= 11, you can use:
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
Updated::: If you want have zoom in/out without zoom controls then use the below code(copied from here)
public class Main extends Activity {
private WebView myWebView;
private static final FrameLayout.LayoutParams ZOOM_PARAMS =
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
myWebView = (WebView)findViewById(R.id.webView);
FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = myWebView.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.GONE);
myWebView.loadUrl("http://www.almondmendoza.com");
}
}
Change this on your AndroidManifest:
android:minSdkVersion="8"
to this:
android:minSdkVersion="11"
than use this in your web view settings:
getSettings().setBuiltInZoomControls(true);
getSettings().setDisplayZoomControls(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With