问题
I have a NestedSCrollView
inside CoordinatorLayout
. In the NestedSCrollView
there is a ViewPager
. I put a fragment view in it containing WebView
. The problem is that if the text in the WebView
is very long it gets cut and I can't scroll. How to solve this?
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nest_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabGravity="fill"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
This is the fragment xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<WebView
android:id="@+id/appearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
/>
回答1:
The problem is that ViewPager
does not support wrap_content
. So it has to be precise or match parent
.
Another solution is to override OnMeasure
method of the ViewPager
. Check out this answer.
来源:https://stackoverflow.com/questions/43834846/nestedscrollview-not-scrolling-fully-in-coordinatorlayout