Scrolling view ScrollView is derived from Farmelayout, which is a component used to add a vertical scrollbar to a normal component; ScrollView contains at most one component, and ScrollView's role is to add a vertical scrollbar to the component. (ScrollView's role is very similar to JScrollPane, and they can't even be called real containers.) They just add scroll bars to other containers. By default, ScrollView just adds a vertical scrollbar to other components, and if the app requires a horizontal scroll bar, it can be implemented with another component: Horizontalscrollview. The functions of Horizontalscrollview and ScrollView are basically similar, except that the former adds a horizontal scroll bar, which adds a vertical scrollbar.
Take a look at the application of Horizontalscrollview and ScrollView through a program. Nesting a horizontalscrollview in ScrollView to add horizontal, vertical scroll bars to the app's interface at the same time
Layout/main.xml
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <!--define ScrollView to add a vertical scrollbar to the inside component -3 <ScrollViewxmlns:android= "Http://schemas.android.com/apk/res/android"4 Android:layout_width= "Fill_parent"5 Android:layout_height= "Fill_parent" >6 7 <!--define Horizontalscrollview To add a horizontal scrollbar to the components inside - 8 <Horizontalscrollview9 Android:layout_width= "Fill_parent"Ten Android:layout_height= "Wrap_content"> One <LinearLayoutandroid:orientation= "vertical" A Android:layout_width= "Fill_parent" - Android:layout_height= "Fill_parent"> - <TextViewAndroid:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" - Android:text= " scroll view scrolling View" - android:textsize= "30DP" /> - <TextViewAndroid:layout_width= "Wrap_content" + Android:layout_height= "Wrap_content" - Android:text= " scroll view scrolling View" + android:textsize= "30DP" /> A <TextViewAndroid:layout_width= "Wrap_content" at Android:layout_height= "Wrap_content" - Android:text= " scroll view scrolling View" - android:textsize= "30DP" /> - <TextViewAndroid:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - Android:text= " scroll view scrolling View" in android:textsize= "30DP" /> - <TextViewAndroid:layout_width= "Wrap_content" to Android:layout_height= "Wrap_content" + Android:text= " scroll view scrolling View" - android:textsize= "30DP" /> the <TextViewAndroid:layout_width= "Wrap_content" * Android:layout_height= "Wrap_content" $ Android:text= " scroll view scrolling View"Panax Notoginseng android:textsize= "30DP" /> - <TextViewAndroid:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" + Android:text= " scroll view scrolling View" A android:textsize= "30DP" /> the <TextViewAndroid:layout_width= "Wrap_content" + Android:layout_height= "Wrap_content" - Android:text= " scroll view scrolling View" $ android:textsize= "30DP" /> $ <TextViewAndroid:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - Android:text= " scroll view scrolling View" the android:textsize= "30DP" /> - Wuyi </LinearLayout> the - </Horizontalscrollview> Wu - </ScrollView>
The above interface shows and runs the effect: