NestedSCrollView无法在CoordinatorLayout中完全滚动 [英] NestedSCrollView not scrolling fully in CoordinatorLayout
问题描述
我在CoordinatorLayout
中有一个NestedSCrollView
.在NestedSCrollView
中有一个ViewPager
.我在其中包含了WebView
的片段视图.问题是,如果WebView
中的文本很长,它将被剪切并且我无法滚动.该如何解决?
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>
这是片段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"
/>
推荐答案
问题是ViewPager
不支持wrap_content
.因此必须精确或match parent
.
The problem is that ViewPager
does not support wrap_content
. So it has to be precise or match parent
.
另一种解决方案是覆盖ViewPager
的OnMeasure
方法.查看此 answer .
Another solution is to override OnMeasure
method of the ViewPager
. Check out this answer.
这篇关于NestedSCrollView无法在CoordinatorLayout中完全滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!