Scroll bar of PagedListView from left side to right side of content in Android

262 Views Asked by At

How to move Scroll bar including page up and page down arrows of android PagedListView from left side to right side of the content. Any help is appreciated.

1

There are 1 best solutions below

0
TheWanderer On

I'm not entirely sure why this isn't documented, but it looks like you can specify the side in XML.

Sample:

<androidx.car.widget.PagedListView
    android:id="@+id/whatever"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:scrollBarGravity="right"
/>

This might not work, since I don't actually see the scrollbar's LayoutParams being set after they're changed. In case it doesn't, you can do this yourself in Java with some reflection:

Field mScrollBarViewField = PagedListView.class.getDeclaredField("mScrollBarView");
mScrollBarViewField.setAccessible(true);
PagedScrollBarView mScrollBarView = (PagedScrollBarView) mScrollBarViewField.get(pagedListViewInstance);

FrameLayout.LayoutParams layoutParams =
                (FrameLayout.LayoutParams) mScrollBarView.getLayoutParams();
layoutParams.gravity = Gravity.RIGHT;
mScrollBarView.setLayoutParams(layoutParams);