ScrollView有很多屬性管理它的樣式,如果在xml中設置,可以在<ScrollView >標簽內設置滾動條樣式的屬性:
• android:scrollbars="none",不顯示滾動條,但能夠滾動的;
• android:scrollbarSize,滾動條大小。
修改上面的例子添加這些屬性xml布局文件代碼如下:
- <?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="wrap_content"
- android:scrollbarSize="12dip"
- android:scrollbars="none"
- >
- <LinearLayout android:orientation="vertical"
- android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/hello"
- android:textSize="20dip" />
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/content" />
- </LinearLayout>
- </ScrollView>