Android 带有RecycleView和ViewPager的NestestedScrollView不会向上滚动视图

Android 带有RecycleView和ViewPager的NestestedScrollView不会向上滚动视图,android,android-recyclerview,android-viewpager,android-nestedscrollview,Android,Android Recyclerview,Android Viewpager,Android Nestedscrollview,我试图实现在xml布局中滚动视图,其中包含recycleview和viewpager,但nestedScrollView不会在视图中向上滚动 布局文件 <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh" android:layout_width="match_parent" android:layout_height="match_parent" ap

我试图实现在xml布局中滚动视图,其中包含recycleview和viewpager,但nestedScrollView不会在视图中向上滚动


布局文件

 <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:fillViewport="true"
        >


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/dimen_200">


                <android.support.v4.view.ViewPager
                    android:id="@+id/viewpager_media"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />


                <RelativeLayout
                    android:id="@+id/viewPagerIndicator"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:gravity="center"
                    android:padding="@dimen/dimen_10">

                    <LinearLayout
                        android:id="@+id/viewPagerCountDots"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:gravity="center"
                        android:orientation="horizontal" />


                </RelativeLayout>


            </RelativeLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rc_media"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
        </LinearLayout>

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

我在老师的帮助下想出了解决办法。我只是使用
getItemViewType
Viewpager
作为
RecycleView
的一部分作为行项目,并删除了
NestedScrollView
,所以现在的布局看起来像

mainLayout.xml


干杯

我在老师的帮助下想出了解决办法。我只是使用
getItemViewType
Viewpager
作为
RecycleView
的一部分作为行项目,并删除了
NestedScrollView
,所以现在的布局看起来像

mainLayout.xml

干杯

    mediaAdapter = new MediaDiscoverAdapter(getActivity(), mediaCallbackListener);
    discoverBinding.rcMedia.setNestedScrollingEnabled(false);
    discoverBinding.nestedScroll.setFillViewport(true);
    discoverBinding.rcMedia.setAdapter(mediaAdapter);
    layoutManager = new StickyHeaderLayoutManager();
    layoutManager.setAutoMeasureEnabled(true);
    discoverBinding.rcMedia.setLayoutManager(layoutManager);
<data>

    <variable
        name="MediaDiscoverFragmentNew"
        type="com.hpc.fragments.media.MediaDiscoverFragmentNew" />
</data>


<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">


    <android.support.v7.widget.RecyclerView
        android:id="@+id/rc_media"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />


</android.support.v4.widget.SwipeRefreshLayout>
      if(viewType == HEADER_VIEW) {
        RawMediaTopBinding mediaTopBinding = 
        DataBindingUtil.inflate(mLayoutInflater, R.layout.raw_media_top, parent, false);
        mediaTopBinding.setMediaDiscoverAdapterNew(this);
        return new HeaderViewHolder(mediaTopBinding);
    } else {
        RawMediaBinding inspirationItemsBinding = DataBindingUtil.inflate(mLayoutInflater, R.layout.raw_media, parent, false);
        inspirationItemsBinding.setMediaDiscoverAdapterNew(this);
        return new ItemViewHolder(inspirationItemsBinding);
    }