ScrollView consente di scorrere il contenuto che supera le dimensioni dello schermo,supporta solo lo scorrimento verticale. Per lo scorrimento orizzontale, si utilizza HorizontalScrollView.
Ecco un esempio:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:gravity=”center”
android:orientation=”vertical”>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”ScrollView”
android:textSize=”20sp”
android:textAppearance=”?android:attr/textAppearanceMedium”/>
<ScrollView
android:layout_marginTop=”30dp”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:orientation=”vertical”>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”A”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”B”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”C”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”D”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”E”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”F”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”G”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”H”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”I”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”L”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”M”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”N”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”O”
android:background=”#155BCE”/>
<Button
android:layout_width=”fill_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”P”
android:background=”#155BCE”/>
<Button
android:layout_width=”fill_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”Q”
android:background=”#155BCE”/>
<Button
android:layout_width=”fill_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”R”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”S”
android:background=”#155BCE”/>
<Button
android:layout_width=”match_parent”
android:layout_height=”70dp”
android:layout_margin=”5dp”
android:text=”T”
android:background=”#155BCE”/>
</LinearLayout>
</ScrollView>
</LinearLayout>