NestedSCrollView not scrolling fully in CoordinatorLayout

走远了吗. 提交于 2019-12-24 10:12:02

问题


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>

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!