【问题标题】:Android FragmentTabHost add Horizontal scrollingAndroid FragmentTabHost 添加水平滚动
【发布时间】:2014-01-19 22:01:51
【问题描述】:

我正在为我的一个项目使用 FragmentTabHost。

我的应用中有超过 5 个标签。

如果我使用了一个或两个选项卡,则意味着 TabHost 看起来不错。

如果我添加超过 5 个选项卡,则选项卡主机正在缩小,并且选项卡文本也会显示在第二个链接中。

我只想为我的 tabhost 添加水平滚动。

但是我们可以添加可滑动的标签。但我不想要这个。我只想刷tabhost。不是标签内容。

提前致谢。

【问题讨论】:

    标签: android tabs fragment android-tabhost


    【解决方案1】:

    使用此布局。它仅包含选项卡主机的水平滚动视图。
    注意:只需将水平滚动视图添加到您的选项卡主机栏即可。

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/mainlayout"
    tools:context=".WebView" >
    
    <TabHost 
    
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_gravity="center"
    
    android:layout_height="fill_parent">
    
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_gravity="center"
        android:layout_height="fill_parent">
    
        <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:gravity="center"
            android:background="#C0C0C0"
            android:layout_height="@dimen/tab_sizes" />
    
         </HorizontalScrollView>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_gravity="center"
            android:layout_height="fill_parent"/>
    
    </LinearLayout>
    
    </TabHost>
    
    
    </RelativeLayout>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 1970-01-01
    • 2016-08-09
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    相关资源
    最近更新 更多