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布局文件实现美观的滚动效果。

234

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



