本例介绍了ScrollView 的基本用法,ScrollView 允许用户滚动屏幕以显示大于屏幕的内容,ScrollView 为FrameLayout的子类,因此一般只在ScrollView显示一个子Layout,通常使用方向为垂直方向的LinearLayout作为ScrollView的子View。 ScrollView只支持垂直滚动。
在介绍Layout时已经有不少关于ScrollView 的例子:
- Android ApiDemos示例解析(153):Views->Layouts->ScrollView->1.Short
-
Android ApiDemos示例解析(154):Views->Layouts->ScrollView->2.
Long -
Android ApiDemos示例解析(155):Views->Layouts->ScrollView->3.
Internal Selection
<ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <LinearLayout android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:text=”@string/scrollbar_1_text”/> … <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:text=”@string/scrollbar_1_text”/> </LinearLayout> </ScrollView>