gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:25:28 25 4
gpt4 key购买 nike

如何设置 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);

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

关于android - 如何设置 android Horizo​​ntalScrollView 从右到左的行为(默认从右侧选择选项卡,而不是左侧),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13384149/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com