I want to design a horizontal scroll bar only in the center of the view and it should be attached to the recyclerView. Basically, I want to limit the length of the horizontal scroll bar.
I want to design a horizontal scroll bar only in the center of the view and it should be attached to the recyclerView. Basically, I want to limit the length of the horizontal scroll bar.
UPDATE
Add a horizontal scroll bar to recyclerview , and set the trumb and bg
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:scrollbarStyle="outsideInset"
android:fadeScrollbars="false"
android:overScrollMode="never"
android:scrollbarSize="5dp"
android:scrollbarThumbHorizontal="@drawable/aa_scrollbar"
android:scrollbarTrackHorizontal="@drawable/aa_scrollbar_bg"
/>
aa_scrollbar.xml :
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="@dimen/dpi_80px"
android:left="@dimen/dpi_20px"
android:right="@dimen/dpi_20px">
<shape>
<corners android:radius="@dimen/dpi_10px" />
<solid android:color="?attr/Theme_color" />
</shape>
</item>
</layer-list>
aa_scrollbar_bg.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="@dimen/dpi_20px"
android:right="@dimen/dpi_20px">
<shape>
<corners android:radius="@dimen/dpi_10px" />
<solid android:color="@color/scrollbar_bg" />
</shape>
</item>
</layer-list>
could rejust the para like dpi_20px as you needed.
Add a horizontal scroll bar to recyclerview .May this help you.
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:scrollbarStyle="outsideInset"
android:fadeScrollbars="false"
android:overScrollMode="never"
android:scrollbarSize="5dp"
android:scrollbarThumbHorizontal="#DF9797"
android:scrollbarTrackVertical="#fff"
/>