Android:可滚动标签

ari*_*ets 5 tabs android

我正在开发我的第一个Android应用程序.我正在为我的应用程序使用选项卡式布局.我在开发指南上按照教程进行了操作并遇到了问题.本教程仅使用了三个选项卡,但我还需要更多选项卡.因此,选项卡会调整大小并组合起来.我希望有人可以告诉我如何让它们滚动,就像使用多个标签时在dolphin浏览器中一样.谢谢!

〜阿龙

Gon*_*nan 12

使用Yoel所说的,只需添加: android:fillViewport="trueandroid:scrollbars="none"

到Horizo​​ntalScrollView像这样:

    <HorizontalScrollView 
       android:id="@+id/horizontalScrollView1" 
       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>
Run Code Online (Sandbox Code Playgroud)


mtm*_*ock 1

在这种情况下,您可能不想使用选项卡。相反,您可以将所有“选项卡”放入屏幕顶部的水平线性布局中,包裹在 ScrollView 中,如下所示

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" android:layout_width="fill_parent">
    <LinearLayout 
        android:orientation="horizontal" android:layout_height="wrap_content"
        android:layout_width="fill_parent">

        ...buttons go here...

    </LinearLayout>
</HorizontalScrollView>
Run Code Online (Sandbox Code Playgroud)

我认为这会给你你正在寻找的结果,但请告诉我