微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何设置android Horizo​​ntalScrollView从右到左的行为(默认选中的选项卡从右侧,而不是左侧)

如何设置Horizo​​ntalScrollView以从右向左的方式运行?
认行为是显示的第一个选项卡(认选项卡)来自左侧.
我希望选项卡反向排序,以便第一个认”选项卡位于屏幕的右侧.

我怎么做?
我使用layout_gravity但它不起作用..

这是我的布局代码,包含tabhost和Horizo​​ntalScrollView:

<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);

这个想法是程序化滚动需要延迟才能工作.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐