android: webview doesn’t fit screen size on Android 4+

Developing Toldor sidur app, I met strange behaviour on some devices with Android 4+.
Affected devices:
Samsung Galaxy s3
Samsung Galaxy tab.

The problem was that webview did not fit actual screen size and was extended out of screen from right and bottom.
fix is very simple:

set the following settings to your webview:

webView.setPadding(0, 0, 0, 0);
webView.setInitialScale(100);

This will set your webview scaled to 100% of your screen. This doesn’t affect devices with lower version of Android, so there is no need to specify version in your code.

Leave a Reply

%d bloggers like this: