SamRowley
SamRowley

Reputation: 3485

Align all tabs left in Android to remove Spacing

I current have a TabHost within my app which opens each tab as an Activity in a FrameLayout. The tabs are designed to "Run" into each other, in other words they need to be side by side with no spaces by being aligned to the left. What I have noticed with the Tabbing system in Android is that the tabs all seem to be centered so using the images I need to means there are big spaces between the tabs. Is there any way to align all the tabs to the left and leave the rest of the screen to the right blank, or is there another way to remove the spaces between tabs?

Upvotes: 0

Views: 1743

Answers (1)

Livia Huang
Livia Huang

Reputation: 246

I use the raletivelayout inside the TabHost, outside the TabWidget, say:

<RelativeLayout
                android:id="@+id/tab_layout" android:background="@color/tab_bg_color"
                android:layout_width="fill_parent" android:layout_height="60dip">
                <TabWidget android:id="@android:id/tabs" 
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:paddingLeft="30dip" android:layout_alignParentLeft="true"
                android:layout_marginLeft="0dip" android:layout_marginRight="0dip" >
                </TabWidget>
</RelativeLayout>

Then the tabs are exactly on left. However, if you use the RelativeLayout, when you select from different activities, you will see "jumping" between them...

Upvotes: 1

Related Questions