Android: scrollable tabs

I am currently working on my first Android app. I am using a tab for my application. I followed the tutorial for this in the developer guide and ran into a problem. Only three tabs were used in the tutorial, but I need more. Thus, the tabs are modified and grouped. I was hoping someone would tell me how I can scroll them, for example, in the dolphin browser when using multiple tabs. Thank!

~ Aaron

+5
source share
3 answers

Using what Yoel said, just add:    android:fillViewport="trueand   android:scrollbars="none"

in a HorizontalScrollView, for example:

    <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>
+12
source

TabWidget HotizontalScrollView. , .

    <HorizontalScrollView 
        android:id="@+id/horizontalScrollView1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        >

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

, , , . .

+3

in this case, you probably do not want to use tabs. Most likely, you can put all your β€œtabs” in a horizontal line layout at the top of the screen, wrapped in a ScrollView, like this

<?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>

I think this will give you the result you are looking for, but let me know

+1
source

All Articles