Arranging big number of tabs in Android
Good time! My question is concerned to the arrange of tabs in Android apps. My app consisted 6 pages of tabs and, sure, in the running application these ta开发者_JAVA百科bs decrease to the narrow rectangles - that's really looks bad. So, is there any cases to switch on some features in tabs to add controls with arrows (like in Windows), which are used to manage the visibility of concrete tab. For example, I have six tabs, after start user sees only three and some control to move hidden tabs on screen?
Yehh...... I think you don't need to use narrow rectangles to complete your task. You have better solution to put your TabView in ScrollView.
For example :
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
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:layout_height="wrap_content"/>
</HorizontalScrollView>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
Refrence : Scrolling Tabs in Android
In order to ease your life, you can use a FrameLayout and on top of the TabWidget you can add a HorizontalScrollView with any number of buttons you want.
Then using the onClick method, when you click a specific button of this HorizontalScrollView, you can set the current tab of your activity.
This way you can also have easy theming to your "tabs"... Hope this helps.
精彩评论