HorizontalScrollView does not scroll left in RTL mode

I have a HorizontalScrollView with android:supportsRtl="true"in my application. But instead of scrolling to the left, it still scrolls to the right. How can i fix this?

    <HorizontalScrollView
    android:id="@id/audioScrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/size_normal"
    android:layout_toStartOf="@+id/retakeBtn"
    android:layout_toEndOf="@+id/recordBtn"
    android:background="@drawable/border_drawable"
    android:paddingBottom="@dimen/size_micro"
    android:paddingTop="@dimen/size_micro"
    android:scrollbars="none"
    >

I am running for level 17 api, so the attributes in xml should be fine.

+4
source share
2 answers

look at this example, all you have to do is add this line android:layoutDirection="rtl"to the attributeHorizontalScrollView

<HorizontalScrollView
    android:id="@+id/horizontalScrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layoutDirection="rtl">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="2" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="3" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="4" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="5" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="6" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="7" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="9" />
    </LinearLayout>
</HorizontalScrollView>

enter image description here

remember that viewsinternally HorizontalScrollVieworganizes them depending on ltrorrtl

+2
source

use this code and create an upside down view

final HorizontalScrollView s=(HorizontalScrollView)ll.findViewById(R.id.horizontalScrollView);
    s.postDelayed(new Runnable() {
        public void run() {
            s.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
        }
    }, 100L);
0
source

Source: https://habr.com/ru/post/1616397/


All Articles