ScrollView is a special framelayout that allows users to scroll through a list of views that can be used to make more space than the physical display area. One thing to note is that ScrollView can only contain one view or ViewGroup (this viewgroup is usually linearlayout).
Do not mix listview with ScrollView. ListView is designed to display some relevant information, and ListView has been optimized to display a large number of list lists.
The following main.xml shows a scrollview containing LinearLayout, and includes button and EditText views in linearlayuout:
<?xml version= "1.0" encoding= "Utf-8"?> <scrollview xmlns:android= "http://schemas.android.com/apk/res/" Android "Android:layout_width=" Fill_parent "android:layout_height=" fill_parent "> <linearl Ayout android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android:orientati on= "vertical" > <button android:id= "@+id/button1" android:layout_width
= "Fill_parent" android:layout_height= "wrap_content" android:text= "Button1"/> <button android:id= "@+id/button2" android:layout_width= "Fill_parent" Androi d:layout_height= "Wrap_content" android:text= "Button2"/> <button Andro
Id:id= "@+id/button3" android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android:text= "Button3"/> <edittext android:id=" @+id/txt "android:layout_width=" fill_parent
"android:layout_height=" 600DP "/> <button android:id=" @+id/button4 " Android:layout_width= "Fill_parent" android:layout_height= "Wrap_content" Android:text = "Button4"/> <button android:id= "@+id/button5" Fill_parent "android:layout_height=" wrap_content "android:text=" Button5 "/> </line Arlayout> </ScrollView>
The above code on the emulator effect diagram: