Android SDK有两个滚动组件,HorizontalScrollView和ScrollView。一个是水平滚动,另一个是垂直滚动。两个嵌套使用,可实现水平和垂直滚动。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
<RelativeLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<!-- 此处省略的组件的配置 -->
... ...
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
<RelativeLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<!-- 此处省略的组件的配置 -->
... ...
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>