ScrollView 滚动视图

 

滚动视图用于为其它组件添加滚动条,在默认的情况下,当窗体中内容比较多,而一屏显示不下时,
超出的部分不能被用户所看到.因为Android的布局管理器本身没有提供滚动屏幕的功能.如果
要让其滚动,就要使用滚动视图ScrllView.

 

滚动视图是FrameLayout的子类,因此,在滚动视图中,可以添加任何想要放入其中的组件,但是一
个滚动视图中只能放一个组件,如果要放置多个,可以先放一个存布局管理器.再将要放置的组件
放置到该布局管理器中,在滚动视图中,使用比较多的是线性布局管理器.

 

 1 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:id="@+id/scrollview"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:scrollbars="none" >
 6 
 7     <LinearLayout
 8         android:id="@+id/ll"
 9         android:layout_width="match_parent"
10         android:layout_height="wrap_content"
11         android:orientation="vertical" >
12          
13     </LinearLayout>
14 
15 </ScrollView>
activity_main.xml

相关文章: