2015-12-22 133 views
1

我哈瓦下面的佈局:回收不能滾動內滾動型

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

</android.support.v7.widget.RecyclerView> 

使用LinearLayoutManager的recyclerView,recyclerView的產品,其使用GridLayoutManager另一個recyclerView,設置gridLayoutRecyclerView的高度,但gridLayoutRecyclerView不能滾動內

+0

但您的代碼只有單個可滾動視圖,即RecyclerView。 – Androider

+0

inner recyclerView是recyclerView的一個項目。 – ReCwert

+0

,請用多個RecyclerView和其他信息完全更新代碼。 – Androider

回答

0

試試這個代碼

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

,也指這個http://developer.android.com/training/material/lists-cards.html

檢查執行後,原因似乎如下。如果RecyclerView被放入ScrollView,那麼在測量步驟中其高度未指定(因爲ScrollView allows any height)並且等於最小高度(按照實施方式),該高度顯然爲零。

你有幾個固定此選項:

  • 設置了一定的高度,以RecyclerView
  • 設置ScrollView.fillViewport爲true
  • 或者保持RecyclerView滾動型之外。

如果RecyclerView的高度不受限制 - 當它放入ScrollView時就是這種情況 - 那麼所有適配器的視圖都有足夠的垂直位置並一次創建。

0

這是我出recyclerView佈局

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

然後,出recyclerView有另一個RecyclerView的其中使用GridLayoutManager一個項目,這是該項目的代碼如下:

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

的seatRecyclerView可以不滾動