Skip to content Skip to sidebar Skip to footer

Horizontalscrollview Doesn't Scroll To Left In Rtl Mode

I have HorizontalScrollView with android:supportsRtl='true' in my application. But instead of scrolling to left, it scrolling to right anyway. How would i fix this?

Solution 1:

use this code and create view upside down

final HorizontalScrollView s=(HorizontalScrollView)ll.findViewById(R.id.horizontalScrollView);
    s.postDelayed(new Runnable() {
        publicvoidrun() {
            s.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
        }
    }, 100L);

Solution 2:

look at this example all you have to do is to add this line android:layoutDirection="rtl" to attribute of HorizontalScrollView

<HorizontalScrollViewandroid:id="@+id/horizontalScrollView"android:layout_width="match_parent"android:layout_height="wrap_content"android:layoutDirection="rtl"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="2" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="3" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="4" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="5" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="6" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="7" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="8" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="9" /></LinearLayout></HorizontalScrollView>

enter image description here

remember the views inside HorizontalScrollView will arrange them depending on ltr or rtl

Post a Comment for "Horizontalscrollview Doesn't Scroll To Left In Rtl Mode"