How to reverse Scrollbar of the HorizontalScrollView

150 Views Asked by At

I'm trying to make an HoziontalScrollView with items :

enter image description here

When I move the scrollbar to the left, the HoziontalScrollView goes right and vice versa, which will make the user confused about how to use the scrollbar to scroll instead of moving finger over the HoziontalScrollView

XML :

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:fadeScrollbars="false"
    android:scrollbarStyle="outsideInset"
    android:scrollbarThumbHorizontal="@drawable/outer_windows_background"
    android:scrollbarTrackHorizontal="@drawable/scrollbar_track_horizontal"
    tools:showIn="@layout/activity_photo_editor">

    //ITEMS

</HorizontalScrollView>

Thank you.

1

There are 1 best solutions below

0
Arsh On

Try this :

HorizontalScrollView hsv;
hsv.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
        event.setLocation(-1*event.getX(), event.getY());
        hsv.dispatchTouchEvent(ev);
        return true;
    }
})