Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何设置android HorizontalScrollView从右向左的行为(默认选择右侧的选项卡,而不是左侧的选项卡)_Android_Android Ui_Android Tabs - Fatal编程技术网

如何设置android HorizontalScrollView从右向左的行为(默认选择右侧的选项卡,而不是左侧的选项卡)

如何设置android HorizontalScrollView从右向左的行为(默认选择右侧的选项卡,而不是左侧的选项卡),android,android-ui,android-tabs,Android,Android Ui,Android Tabs,如何将HorizontalScrollView设置为从右向左的方式? 默认行为是显示的第一个选项卡(默认选项卡)位于左侧。 我希望选项卡按相反顺序排序,以便第一个“默认”选项卡位于屏幕右侧 我该怎么做? 我用了重力,但没用 这是我的布局代码,包含tabhost和HorizontalScrollView: <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/ta

如何将HorizontalScrollView设置为从右向左的方式? 默认行为是显示的第一个选项卡(默认选项卡)位于左侧。 我希望选项卡按相反顺序排序,以便第一个“默认”选项卡位于屏幕右侧

我该怎么做? 我用了重力,但没用

这是我的布局代码,包含tabhost和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>

一个可行的解决方案:

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

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

这个想法是,编程滚动需要一段时间才能正常工作。

我相信这已经太晚了,但对于其他有类似问题的人来说:

horizontalScrollView.post {
        horizontalScrollView.fullScroll(View.FOCUS_RIGHT)
    }

您不应该使用post的延迟版本。因为post将被添加到消息队列的末尾。

HorizontalScrollView
没有选项卡。