Reputation: 1540
I have a TabHost in my application and I have a problem that can be solved either way:
1) Reduce the font size of the text inside each tab.
2) Make the TabHost scroll-able so that the tabs aren't "scrunched".
Could you guys help me produce one of these two outputs?
I've already tried using a theme defining text size and referring to it through the android manifest inside the activity tag of the activity that holds the TabHost.
If needed I'll edit this post with my xml and class files.
https://i.sstatic.net/jeCIN.png
Upvotes: 3
Views: 1460
Reputation: 13761
I recommend the second aproach. That's the one I've always used and it works like a charm. It consist in wrapping the TabWidget in a HorizontalScrollView with the scrollbar="none" attribute.
For instance (in your layout file):
<TabHost
android:id="@+android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/TabLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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="wrap_content"
android:layout_height="wrap_content"></TabWidget>
</HorizontalScrollView>
<FrameLayout
android:id="@+android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"></FrameLayout>
</LinearLayout>
</TabHost>
You can find more info here
Upvotes: 4