I use support.v4.widget.NestedScrollView and i have an issue with my webview.
Here is my layout:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/barlayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:background="#9E9E9E"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout"
android:animateLayoutChanges="true">
<!-- some views here -->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/webView"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/dialog_location"
android:id="@+id/dialog"
android:visibility="invisible"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
with this layout the webview have to much scroll (sorry for the link, i cant post images)
https://drive.google.com/open?id=0B7otV-_1sdEvUWRzSjlHY01fY3c
and if i change webview to wrap_content the webview is small
<WebView
android:id="@+id/webView"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
https://drive.google.com/open?id=0B7otV-_1sdEvbVFSRlR0a2IxeUk
We are doing the exact same thing. This has been triaged to the developers and designers at google. The solution provided as of the moment is not to use Android webviews inside NestedScrollView.
Here is an excerpt from the thread here:
This is WAI.
If you put webview in a NestedScrollView, height is wrap_contents, and the webview expands to the size of the page. This is as if in desktop, you resize the browser window to height of the page so it can't scroll vertically. The scrolling is happening in NestedScrollView rather than webview itself.
So a consequence of no js in the page sees any scroll events, so it doesn't know you've scrolled to the end of the page load more content.
Also hardware layers is backed by GL textures, and they have a maximum size (which is least the screen size, although usually not much bigger). If a view becomes larger than the maximum texture size, then it won't work with a hardware layer. This applies to any view, not just webview.
Solution: don't put webview in a NestedScrollView. don't use webview in wrap_contents mode. Let webview scroll the web page itself.
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