2017-01-05 96 views
0

我正在做一个布局,两个recyclerview与中间的文本视图分隔。现在我希望整个布局可以滚动,我现在有一个textview卡在中间,布局不可滚动,我试图用scrollview包装它们,但没有工作,仍然是相同的行为。 如何让整个布局可以滚动?Android可滚动布局与recyclerview

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" android:layout_height="match_parent"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/today_booking_recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#e8d6b6" 
    > 

</android.support.v7.widget.RecyclerView> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/today_booking_recycler_view" 
     android:id="@+id/tvRelativeLayout" 

     > 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="seperator" 
      android:textColor="#FF0000" 
      android:padding="@dimen/activity_horizontal_margin" 
      /> 
    </RelativeLayout> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/my_booking_recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tvRelativeLayout" 
     > 

    </android.support.v7.widget.RecyclerView> 
</RelativeLayout> 
+0

你不能让RecyclerView内RecyclerView。 –

+0

我想你需要使用'NestedScrollView'。 https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html –

回答

0

您可以使用此滚动整个布局: -

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

// your layout which has to be scrolled 

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