java - Android 2.3.3,使选项卡列表可滚动?

标签 java android android-layout tabs

我找到了这个简单的布局作为示例:

<?xml version="1.0" encoding="utf-8"?>
<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:layout_alignParentBottom="true"
            android:fillViewport="true"
            android:scrollbars="none" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center" />
        </HorizontalScrollView>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </FrameLayout>
    </LinearLayout>

</TabHost>

在代码中添加 8 个选项卡后,我可以看到它们被挤在一起。 如何向选项卡添加可滚动功能? (只是选项卡,不是内容)

我手机上的一个应用程序具有此功能,并且也是在没有任何滚动条的情况下完成的。基本上,要移动,我只需按下并按住,然后将选项卡拖动到左侧即可显示更多选项卡。如何实现这一目标?

最佳答案

你试过这个吗?

<HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </TabHost>

</HorizontalScrollView>

关于java - Android 2.3.3,使选项卡列表可滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10880978/

相关文章:

java - 为什么新线程立即操作UI时没有CalledFromWrongThreadException?

android - 找不到google-play-services_lib

android - 更改背景后手指绘画变慢

java - 在相对布局中显示 AChartEngine

android - 抽屉中的可滚动页脚

java - Android Wear NullPointerException 无法在 TextView 上设置文本

java - Android - 从 Activity 外部调用函数(通过 AlarmManager 和通知)

java - 基于文本的冒险游戏线程 "main"java.lang.NullPointerException 中的异常

java - 即使在 Websphere 中应用程序已停止后,线程仍会继续运行

java - 如何在 TextView 的文本周围设置边框