1

I have Set the tabview in My Application But all tab shows very near to eachother. . i want to Set the Little Space between then. . . How it is Possible ? Thanks in Advance.

richq
  • 55,548
  • 20
  • 150
  • 144
  • Shreyash, please stop with the tag spam. Your questions are never related to android-ndk, android-emulator or android-widgets, so *don't use those tags*. Thanks. – richq Apr 26 '11 at 14:23

3 Answers3

0

You can add space in the tabview item by giving a margin inside that. Use the code below.

for(int i=0; i < mTabLayout.getTabCount(); i++) {  
     View tab = ((ViewGroup) mTabLayout.getChildAt(0)).getChildAt(i); 
     ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) 
     tab.getLayoutParams(); > p.setMargins(0, 0, 50, 0); > tab.requestLayout();
}

rghome
  • 8,529
  • 8
  • 43
  • 62
0

You could use setIndicator(View) to build tab from own view, and in your custom view (inflated for example from the XML) set the proper margins / paddings. Refere to my post for more info.

Community
  • 1
  • 1
Kocus
  • 1,613
  • 17
  • 31
0

<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">
        <View android:layout_width="fill_parent" android:layout_height="0.5dip"

Here, I set 0.5 you can st 1 dp and you can set a tabdiver.9.png file.

            android:background="#000" />
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent" android:layout_height="55dip"
            android:layout_marginLeft="0dip" android:layout_marginRight="0dip" />
        <View android:layout_width="fill_parent" android:layout_height="5dip"
            android:background="#696969" />
        <View android:layout_width="fill_parent" android:layout_height="1dip" 
            android:background="#000" />
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent" android:layout_height="fill_parent" />
    </LinearLayout>
</TabHost>

Try this.

Pang
  • 9,564
  • 146
  • 81
  • 122
Maidul
  • 1,289
  • 16
  • 30