ScrollView 的滚动条背景和滑块可以定制,本例使用drawable 为ScrollView定制了滚动条和滑块,滚动条宽度设为12dip ,滑块为蓝色等
<ScrollView xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:scrollbarTrackVertical=”@drawable/scrollbar_vertical_track”
android:scrollbarThumbVertical=”@drawable/scrollbar_vertical_thumb”
android:scrollbarSize=”12dip”>
<LinearLayout
android:orientation=”vertical”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>
<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/scrollbar_2_text”/>
…
<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/scrollbar_2_text”/>
</LinearLayout>
</ScrollView>
本文介绍如何使用Android的ScrollView组件并自定义其滚动条的外观,包括设置滚动条背景及滑块颜色。通过指定XML属性,可以实现滚动条宽度及滑块颜色的定制。

233

被折叠的 条评论
为什么被折叠?



