ScrollView
Description
A ScrollView is a special type of FrameLayout which support scrolling through a list of views that occupy more space than the physical display.
The ScrollView can contain only one child view or ViewGroup, which normally is a LinearLayout.
Do not use a ListView together with the ScrollView.
Example
The following main.xml content shows a ScrollView containing a LinearLayout, which in turn contains some Button and EditText views:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 2" />
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 3" />
<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="Button 4" />
<Button
android:id="@+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 5" />
</LinearLayout>
</ScrollView>
Note
Because the EditText automatically gets the focus, it fills up the entire activity.
To prevent it from getting the focus, add the following two attributes to the
<LinearLayout>
element:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true" >
You will now be able to view the buttons and scroll through the list of views.