how to set android HorizontalScrollView right-to-left behavior (default selected tab from the right side, not the left)

android, android-tabs

Solution

One workaround that works:

final HorizontalScrollView view = (HorizontalScrollView) findViewById(R.id.scroller);
        view.postDelayed(new Runnable() {

            @Override
            public void run() {
                view.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
            }
        }, 10);

The idea is that programmatic scrolling needs a delay for it to work.

Problem

how do I set the HorizontalScrollView to behave in a right-to-left manner? The default behavior is that the first tab (the default tab) that is shown is from the left side . i want the tabs to be sorted in reverse,so that the first 'default' tab will be on the right side of the screen. how do i do that? I used layout_gravity but it didn't work .. Here is my layout code , containing the tabhost and the HorizontalScrollView : ``` <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true" android:scrollbars="none"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </HorizontalScrollView> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> </TabHost> ```

Original source