2017-05-29 51 views
0

我想有一個回收者視圖與整個父母一起滾動,但目前它正在其微小的空間內滾動。如何使recyclerView與父級垂直滾動?

我有一個Android的佈局,像這樣

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    <SwipeRefreshLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView /> 
       <RecyclerView 
        android:layout_width="match_parent" 
        android:layout_height="150dp" /> <- this scrolls horizontally 

       <TextView /> 
       <RecyclerView 
        android:layout_width="match_parent" 
        android:layout_height="150dp" /> <- this scrolls horizontally 
          <- at this point the screen is half filled 

       <TextView /> 
       <RecyclerView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> <- I wish this to scroll vertically 
          <- but I want the whole screen to scroll, not just half the screen. 
          <- And as user scrolls down, this recycler view should be able to grow itself for pagin.. 

      </LinearLayout> 
     </NestedScrollView> 
    </SwipeRefreshLayout> 
</LinearLayout> 

我的問題是,如何使第三回收觀點與一切一起滾動?目前由於某種原因,它以50%的屏幕高度滾動。

+0

在你nestedscrollview應該只有一個孩子 – AbhayBohra

回答

1

添加setNestedScrollingEnabled(false);您recyclerview

RecyclerView v = (RecyclerView) findViewById(...); 
v.setNestedScrollingEnabled(false);