2017-01-05 95 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>