Maxim Naidovich Maxim Naidovich - 11 months ago 133
Android Question

How can I change direction of scrolling from right to left in HorizontalScrollView

I build a calculator. I put some symbols on the right side of the screen. When size of the screen is not enough, symbols on the left side disappear and HorizontalScrollView add some space to the right side.

enter image description here

enter image description here

How can I change directon of scrolling form left to right?

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/top_scr_v"
android:layout_marginTop="@dimen/standard_view_margin">

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/top_scr_hor_sc_v"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/resultValue"
android:textColor="@color/mainColor"
android:textSize="@dimen/display_text_size"
/>
</HorizontalScrollView>

</ScrollView>

Answer Source

After API 17 you can use android:layoutDirection="rtl" , before android:supportsRtl="true".