'Changing scroll bar style does not effect its height xml java android studio
I am trying to change the style of Scrollbar of a GridView. The new style I created is applied successfully but unfortunately the length and width of scroll bar still remains default. How do I change them.
This is my custom_scroll_bar_thumb.xml inside my drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:aapt="http://schemas.android.com/aapt">
<item>
<shape android:shape="rectangle">
<solid android:color="#0288d1"/>
<size android:height="10dp" android:width="5dp"/>
<corners android:radius="10dp"/>
</shape>
</item>
<item android:gravity="center_vertical|center_horizontal|center|clip_vertical" android:height="4dp" android:width="4dp" android:drawable="@drawable/up_and_down" android:top="2dp" android:bottom="2dp"/>
</layer-list>
As you can see I have defined its height and width here. But it does not seem to take any effect.
After this I created a style named custom_scroll_bar in my styles.xml, like this:
<style name="custom_scroll_bar">
<item name="android:scrollbarAlwaysDrawVerticalTrack">true</item>
<item name="android:scrollbarStyle">outsideOverlay</item>
<item name="android:scrollbars">vertical</item>
<item name="android:fadeScrollbars">false</item>
<item name="android:scrollbarThumbVertical">@drawable/custom_scroll_bar_thumb</item>
</style>
Now I have used it inside my grid view like with
style="@style/custom_scroll_bar"
This is my grid view:
<GridView
android:id="@+id/galleryViewGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="5dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingEnd="5dp"
android:numColumns="3"
android:horizontalSpacing="8dp"
android:verticalSpacing="8dp"
style="@style/custom_scroll_bar"
android:stretchMode="columnWidth">
</GridView>
This is the output I am getting:
As you can see the scroll bar still has default height and width. How can I change that. Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

