Reputation: 47
I am scaling my webview to fit the content to the width of the screen using the following code:
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
This works but now I am getting an empty space at the bottom of the content. The size (in height) of the empty space is directly proportional to the magnitude of the zoom it is doing. So for smaller devices, the size is greater.
My feeling is that scroll bars size are not being recalculated after the zoom has taken effect. This assumption is due to the fact that when zooming-in and out by tapping on the screen, empty space goes away. Although this is working on Android 2.3 but not on 4.0.
My question how to force the scrollbars to recalculate after the zoom. Or is there any other solution.
Thanks.
P.S. Here is how I defined the webview in xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/web_view"
android:background="#AAFFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Upvotes: 3
Views: 11099
Reputation: 7065
Why do you have a webview within a linearlayout within a scrollview, first of all? A WebView inherits from scrollView and implements it's own scrolling, so what is the other scrollview for? Essentially you will have a scroller within a scroller!!! Secondly I do see that you have "wrap_content"
for your WebView' android:layout_height
property.
Upvotes: 7