Which Recyclerview or ScrollView should I choose?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Which Recyclerview or ScrollView should I choose?



I created an activity with a ListView. That is a Friend ListView.


ListView


ListView



I wanna let it choose to add it to another View.


View



I don't know which View to choose is the best. Recyclerview or ScrollView?


View


Recyclerview


ScrollView



Like this



enter image description here





Recommend you to use RecyclerView for both. Just you need to set the direction HORIZONTAL for top layout and for the bottom VERTICAL.
– Krishna Sharma
Aug 8 at 7:20


RecyclerView


HORIZONTAL


VERTICAL




5 Answers
5



Nowadays we use the RecyclerView. it was introduced with the Android Lollipop and it proved to be a game changer. A lot of things that we hate in the ListView were fixed or changed in the RecyclerView. It’s more efficient by default, the layout is separated and we have more possibilities over the data set inside the adapter.



I recommend to user always RecyclerView and never a ListView. Use RecyclerView for element list and scrollview for static views.



Seeing your image Scrollview inside RecyclerView or ListView have problems with drag.



Use a vertical RecyclerView in all page and horizontal RecyclerView each row.





So my ListView has to change into a RecyclerView ?
– JerryLi
Aug 8 at 7:19





In my opinion always.
– SergioCT
Aug 9 at 7:30



I suggest you to use RecyclerView because you will load lots of images and if you use ScrollView eventually you will use so much memory. Also it is recommended to use RecyclerView when you have dynamic data. You can look the definition of the RecyclerView in the Android Documentation as follow



RecyclerView is a view for efficiently displaying large data sets by
providing a limited window of data items.



You can use nested RecyclerView for creating such hierarchal view.
You can also checkout this example for nested RecyclerView usage.



Also you can further read:



I hope this helps.



Basic difference between RecyclerView and ListView are the below.


RecyclerView


ListView



ListView is simple to implement. Default Adapters available.
But ViewHolder pattern and finding views using ID's used to give slow performance.


ListView


ViewHolder



Now in RecyclerView , the above problems are attended using RecyclerView.ViewHolder.
For RecyclerView adapter, this ViewHolder is mandatory. While comparing to list view this is kinda complex, but solves performance issues in ListView.


RecyclerView


RecyclerView


ViewHolder


ListView



Difference LayoutManagers are available while using RecyclerView.


LayoutManagers


RecyclerView



Major improvement of RecyclerView performance while comparing to ListView would be this according to developer.android.com



The RecyclerView creates only as many view holders as are needed to
display the on-screen portion of the dynamic content, plus a few
extra. As the user scrolls through the list, the RecyclerView takes
the off-screen views and rebinds them to the data which is scrolling
onto the screen



To sumup, RecyclerView is preferable than ListView (when UI is having same widgets repeating according to your data)



Now when to use ScrollView:


ScrollView



Your UI elements may not show completely in small device screens. But in bigger screen sizes it may!
Elements may not be necessarily only list / grid. It can have combinations of any UI widgets.



Eg:- TextViews vertically , with RadioButton and Button at last for user action.


TextViews


RadioButton


Button



This cannot be included in ListView/ RecyclerView , now you can add ScrollView which will have a LinearLayout/RelativeLayout . Inside which all other elements can be added.


ListView


RecyclerView


ScrollView


LinearLayout


RelativeLayout



Now you can






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS