NestedSCrollView无法在CoordinatorLayout中完全滚动 [英] NestedSCrollView not scrolling fully in CoordinatorLayout

查看:74
本文介绍了NestedSCrollView无法在CoordinatorLayout中完全滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CoordinatorLayout中有一个NestedSCrollView.在NestedSCrollView中有一个ViewPager.我在其中包含了WebView的片段视图.问题是,如果WebView中的文本很长,它将被剪切并且我无法滚动.该如何解决?

I have a NestedSCrollView inside CoordinatorLayout. In the NestedSCrollViewthere 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.

另一种解决方案是覆盖ViewPagerOnMeasure方法.查看此 answer .

Another solution is to override OnMeasure method of the ViewPager. Check out this answer.

这篇关于NestedSCrollView无法在CoordinatorLayout中完全滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆