Reputation: 451
I have a WebView with large text content. I'm using the following WebView settings:
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);
The Html viewport settings are:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
The problem is that the scrollbar is going outside the layout, as follow:
My Android Layout is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<LinearLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
Upvotes: 7
Views: 1672
Reputation: 3729
You can add padding to parent layout
<WebView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:padding="3dp"/>
Upvotes: 0
Reputation: 21
try this :-
<WebView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView" />
i fix this issue with this code
Upvotes: 1
Reputation: 451
I fixed the issue by adding the following on the WebView layout:
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
Upvotes: 1