带有TabLayout&的片段中的NestedScrollView ViewPager无法滚动

时间:2017-01-19 18:42:59

标签: android android-fragments android-viewpager android-scrollview android-tablayout

我将NestedScrollView添加到我的片段中,如下面的代码片段。

我正在使用FragmentPagerAdapter在ViewPager中显示片段内容。 (关注this article

内容填充正常,但我无法滚动。

main_fragment.xml

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1"
        android:background="@color/feed_grey_background" >

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/default_gap_1_5x">
        </LinearLayout>

        <android.support.design.widget.TabLayout
            android:id="@+id/sliding_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed" />

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@android:color/holo_blue_light" />

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

tabview_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/postList"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

更新

如果我删除recyclerView.setNestedScrollingEnabled(false);

,我可以滚动回收站视图(而非nestedscrollview)

0 个答案:

没有答案