Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView inside NestedScrollview alternative

I have a layout with this hierarchy

< NestedScrollView fillViewPort=true>
< LinearLayout>
< Viewgroup/>
< ViewGroup/>
< RecyclerView/>
< ViewGroup/>
< /LinearLayout>
< /NestedScrollView>

Sometimes i need to update my recyclerview elements, but it freeze main thread. My guess its because scrollview need to measure it all again. I really like to know how i should do this?

  • Replace recyclier view with layoutinlfate?
  • Recyclerview with height fixed?
  • Replace nestedscrollview, with recyclview? will have recyclview inside reclyerview. This works?
like image 660
user1851366 Avatar asked Sep 30 '20 10:09

user1851366


People also ask

Can we use RecyclerView inside RecyclerView in Android?

The RecyclerView widget manages the display and handling of items in a list. It provides Layout Managers to position these items. This way, you can create customized layout managers for RecyclerView containers. We can use a RecyclerView inside another RecyclerView.

Can we use nested RecyclerView in Android?

A nested RecyclerView is an implementation of a RecyclerView within a RecyclerView. An example of such a layout can be seen in a variety of apps such as the Play store where the outer (parent) RecyclerView is of Vertical orientation whereas the inner (child) RecyclerViews are of horizontal orientations.

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false.


1 Answers

This is a common UI pattern and android:nestedScrollingEnabled="true" is not a fix for this.

Best approach to this pattern is to use a single recyclerview with multiple view types instead of having nested elements. The result is a more complicated recyclerview but you have better performance and more control with it.

like image 110
Nezih Yılmaz Avatar answered Oct 31 '22 10:10

Nezih Yılmaz