Reputation: 4268
I'm currently working on my first android application. I am using a tabbed layout for my application. I followed the tutorial for this on the dev guide and ran into a problem. The tutorial only used three tabs, but I have a need for more. As such, the tabs resize and bunch up. I was hoping someone could tell me how I can make them scroll, like in dolphin browser when using multiple tabs. Thanks!
~aaron
Upvotes: 5
Views: 9806
Reputation: 773
Using what Yoel said, just add:
android:fillViewport="true
and
android:scrollbars="none"
to HorizontalScrollView like this:
<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>
Upvotes: 12
Reputation: 1814
I would recommend to wrap the TabWidget with HotizontalScrollView instead. this way you can still use the tabs as they are.
<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>
It is important to note that if you are using less tabs, this will cause the tab's not to fill the whole width of the screen. I am currently looking for a solution for this issue.
Upvotes: 3
Reputation: 13062
in this case you probably dont want to use tabs. Rather, you can put all of your "tabs" in to a horizontal linear 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 that this will give you the result you are looking for, but let me know
Upvotes: 1