I created an activity with a ListView
. That is a Friend ListView
.
I wanna let it choose to add it to another View
.
I don't know which View
to choose is the best. Recyclerview
or ScrollView
?
Like this
I created an activity with a ListView
. That is a Friend ListView
.
I wanna let it choose to add it to another View
.
I don't know which View
to choose is the best. Recyclerview
or ScrollView
?
Like this
Basic difference between RecyclerView
and ListView
are the below.
ListView
is simple to implement. Default Adapters available.
But ViewHolder
pattern and finding views using ID's used to give slow performance.
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
.
Difference LayoutManagers
are available while using 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
:
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.
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.
Now you can
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.
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.