HorizontalScrollView 在 RTL 模式下不会向左滚动 [英] HorizontalScrollView doesn't scroll to left in RTL mode
问题描述
我的应用程序中有带有 android:supportsRtl="true"
的 HorizontalScrollView.但它不是向左滚动,而是向右滚动.我该如何解决这个问题?
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?
<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"
>
我正在运行 17 级 API,因此 xml 中的属性应该没问题.
I am running for 17 level api, so attributes in xml should be fine.
推荐答案
看这个例子 你所要做的就是把这行 android:layoutDirection="rtl"
添加到 HorizontalScrollView
look at this example all you have to do is to add this line android:layoutDirection="rtl"
to attribute of HorizontalScrollView
<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>
记住 HorizontalScrollView
中的 views
会根据 ltr
或 rtl
remember the views
inside HorizontalScrollView
will arrange them depending on ltr
or rtl
这篇关于HorizontalScrollView 在 RTL 模式下不会向左滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!