当前位置:操作系统 > 安卓/Android >>

Android ApiDemos示例解析(188):Views->ScrollBars->1.Basic

本例介绍了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
[html]
<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> 

<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>

 \

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,