I'm having an issue in my WebView with Android 4.4. Before KitKat, text was fitting automatically with all devices resolutions in webviews. But today it's not fitting automatically anymore with 4.4. I think it's because of the WebView's update based on Chromium with KitKat.
Here are 2 screenshots of the same page :
One from Galaxy Nexus (Android 4.3)
One from Nexus 5 (Android 4.4 and WebView based on Chromium)
Do you know if there is a new option to fit text with screen in webview ?
NB: I don't think my layout as something to do with my issue but here it is anyway:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
If you can edit the html (using a simple string replace for instance), add the style word-wrap: break-word to the text container html element. e.g: If the top level element inside the body of the html is <p>
, change to<p style="word-wrap: break-word;">
. The webview will then wrap around the text and fit to screen.
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