You can get the view you get from WebView.getZoomControls () and add it as a child to the layout next to (or on top of) the webview. Unfortunately this is hacked, getZoomControls is deprecated, and you wonβt get a pinch of zoom unless you call WebSettings.setBuildInZoomControls (true) (which will add the SECOND zoom controls view that you don't need), but it seems to work. Here is my code to do this for what it stands:
Xml layout:
<RelativeLayout android:id="@+id/rl" android:layout_width="fill_parent" android:layout_height="fill_parent"> <WebView android:id="@+id/wv" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <FrameLayout android:id="@+id/wv_zoom_fl" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" /> </RelativeLayout>
Java (inside the action):
WebView wv = (WebView)findViewById(R.id.wv); FrameLayout zoomfl = (FrameLayout)findViewById(R.id.wv_zoom_fl); zoomfl.removeAllViews(); zoomfl.addView(wv.getZoomControls());
Now, to zoom out, you can set the visibility of R.id.rl (which contains the WebView and FrameLayout containing the zoom controls) to RelativeLayout.GONE.
For a disappointing solution: if your minimum Api is set to level 11 (which is Honeycomb 3.0, unfortunately, this is unlikely), you can use: http://developer.android.com/reference/android/webkit/WebSettings.html#setDisplayZoomControls (boolean)
ubzack
source share