Is there a way to customize the standard scrollbar that ListView provides in android..? I haven't got a definitive answer on this yet :/
Create a theme in res/styles.xml
:
<style name="CustomTheme" parent="android:Theme">
<item name="android:scrollbarTrackVertical">@drawable/scroll_track</item>
<item name="android:scrollbarThumbVertical">@drawable/scroll_thumb</item>
</style>
@drawable/scroll_track
and @drawable/scroll_thumb
must refer either to nine patch images or to a shape drawables. Scroll track image is a background for the scroll bar. Scroll thumb is responsible for the scroll handle. Then just apply the theme either to whole application or to an activity within AndroidManifest.xml:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/CustomTheme">
You can also specify it in the ListView or ScrollView that is in your layout. I have a provided a screenshot example from my code:
enter image description here
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/divider_bar"
android:layout_marginTop="5dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:fadeScrollbars="true"
android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track"
android:scrollbarFadeDuration="500"
android:scrollbarDefaultDelayBeforeFade="1000">
</ListView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With