2017-08-13 13 views
1

NestedScrollViewの中に2つのRecyclerViewを使用しています。セットアップは素晴らしいですが、私はそれが持つことができるメモリの影響について心配しています。 RecylerViewがコンポーネントをリサイクルするかどうかはわかりません。これには他の弱点がありますか?ここでRecyclerViewはNestedScrollView内のアイテムをリサイクルしますか?

はいくつかのコードです:それはNestedScrollView内にあるとき

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/nested_coordinator_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginBottom="54dp" 
    android:background="@color/white" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <RelativeLayout 
     android:id="@+id/toplayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white"> 

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

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycleview2" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/recycleview1" 
      android:nestedScrollingEnabled="false"/> 

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

答えて

2

RecyclerViewは、そのアイテムをリサイクルしません。実際には、ビューのsetNestedScrollingEnabled(false)を完全に展開し、親のスクロール動作はNestedScrollViewである必要があります。したがって、無限のRecyclerViewがある場合、アイテム数が増えるとメモリとパフォーマンスが低下します。しかし、あなたのアイテムの数がメモリとパフォーマンスに影響を与えるほど大きくない限り、をNestedScrollViewの中に入れても間違っているわけではありません。しかし、そうしない方が良いことは明らかです。

関連する問題