2

I am using FragmentTabHost for one of my project.

I have more than 5 tabs in my app.

If i used one or two tabs means the TabHost looking good.

If i add more than 5 tabs, The tabhost is shrinking and the tab text showing in a second link also.

I want to add Horizontal scroll only for my tabhost.

However we can add swipe able tab. but i don't want this. i want to swipe only the tabhost. not the tab content.

Thanks in advance.

Amarnath
  • 1,091
  • 3
  • 19
  • 32

1 Answers1

2

Use this layout. It includes horizontal scroll view for tab host only.
Note: just add the horizontal scrollview to your tab host bar.

<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>
Nunser
  • 4,512
  • 8
  • 25
  • 37
harikrishnan
  • 1,985
  • 4
  • 32
  • 63
  • 1
    However this answer is not about FragmentTabHost but about old TabHost. The correct answer (FragmentTabHost related) could be found here - http://stackoverflow.com/questions/14598819/fragmenttabhost-with-horizontal-scroll – Stan Jan 03 '14 at 18:40