Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ScrollView and ListView

Can any one explain the difference between Scroll View and List View? When to use which one? And which one is more efficient?

like image 762
Farooq Arshed Avatar asked Mar 22 '12 10:03

Farooq Arshed


People also ask

What is the difference between ScrollView and RecyclerView?

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.

What is the difference between ScrollView and horizontal ScrollView?

ScrollView and HorizontalScrollView has same attributes, the only difference is scrollView scroll the child items in vertical direction while horizontal scroll view scroll the child items in horizontal direction.

Are ListView scrollable?

Show activity on this post. Never put ListView in ScrollView . ListView itself is scrollable.

Is ScrollView scrollable?

Scroll view supports vertical scrolling only. For horizontal scrolling, use HorizontalScrollView instead. Never add a RecyclerView or ListView to a scroll view.


2 Answers

ScrollView is used to put different or same child views or layouts and the all can be scrolled.

ListView is used to put same child view or layout as multiple items. All these items are also scrollable.

Simply ScrollView is for both homogeneous and heterogeneous collection. ListView is for only homogeneous collection.

like image 137
Yugandhar Babu Avatar answered Oct 15 '22 10:10

Yugandhar Babu


They're completely different.

A ScrollView is simple a scrolling container you can use to scroll whatever you put inside it, which might be a list of items, or it might not.

http://developer.android.com/reference/android/widget/ScrollView.html

A ListView is very specifically designed to hold lists, where items typically look the same (or at least follow a pattern, e.g. section headings). ListView is also designed to connect to a data source of some sort, SQLite, array, content provider etc. ListView can scale to handle enormous numbers of list items.

http://developer.android.com/resources/tutorials/views/hello-listview.html

If you have data you need to show in a list, use a ListView. If you just need scrolling content, then a ScrollView is probbaly enough.

like image 28
Ollie C Avatar answered Oct 15 '22 10:10

Ollie C