حتما تاکنون صفحاتی را دیده اید که اندازه آنها، بزرگتر از صفحه نمایشگر گوشی است و کاربر می تواند در آنها، با کشیدن انگشت خود به سمت بالا یا پایین، بخش هایی از صفحه را که در نمایشگر گوشی نمایش داده نشده است را ببیند. برای ساخت اینگونه صفحات، باید در فایل xml متناظر با activity این صفحات، کدهای زیر را بنویسیم :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_simple_3" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
همان طور که مشاهده می کنید، از تگ ScrollView استفاده کرده ایم که قابلیت اسکرول به بالا و پایین را به وجود می آورد. سپس در میان تگ های ScrollView ، تگ های LinearLayout را نوشته ایم. اکنون اگر بخواهیم مثلا یک دکمه (Button) به صفحه اضافه کنیم، باید کد مربوط به آن را در میان تگ های LinearLayout بنویسیم. مثل کد زیر :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_simple_3" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="@dimen/vertical_space"
android:layout_marginLeft="@dimen/horizontal_space"
android:layout_marginRight="@dimen/horizontal_space"
android:layout_marginTop="@dimen/vertical_space"
android:background="@drawable/background_button_2"
android:padding="@dimen/padding_text"
android:text="@string/subject_45"
android:textSize="@dimen/button_text_size" />
</LinearLayout>
</ScrollView>