看一看ScrollView。它支持像网站一样的滚动行为,允许布局比实际屏幕大小“更大”。
有一点需要注意; A ScrollView
只能包含一个直接孩子。因此,如果您的布局包含若干个Views
,如TextViews
和Buttons
,则必须将它们全部包装在LinearLayout
或RelativeLayout
中。
布局,有很多孩子的的:
<?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">
<LinearLayout id="@+id/wrapper_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView />
<EditText />
<Button />
</LinearLayout>
</ScrollView
当你只得到了一个孩子,你不必“包装”布局:
<?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">
<TextView id="@+id/lots_of_text_that_need_scrolling" />
</ScrollView>
来源
2013-02-26 19:31:34
Ole
你的意思是滚动型? – 2013-02-26 19:15:12
是的,谢谢。 – 2013-02-26 20:01:50