滚动条很简单,就是添加了以后,可以有一个滚动条,实现屏幕的滚动。
在一个垂直滚动条里添加了一个水平滚动条。
<?xml version="1.0" encoding="utf-8"?> <!-- 定义ScrollView,为里面的组件添加垂直滚动条 --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!-- 定义HorizontalScrollView,为里面的组件添加水平滚动条 --> <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图" android:textSize="30dp" /> </LinearLayout> </HorizontalScrollView> </ScrollView>