I want this spacing between the tabs removed, How can this be achieved ?
-
1This has been answered here: http://stackoverflow.com/questions/5799320/android-remove-space-between-tabs-in-tabwidget/5804436#5804436 – nedaRM Feb 21 '13 at 05:16
-
1hai, i have see that . i can't understand, can u please tell how to use it. – R KiranKumar Feb 21 '13 at 05:22
-
check if you have added margin to you tab child layout – techieWings Feb 21 '13 at 06:01
-
i have add margin, what i want to do please tell – R KiranKumar Feb 21 '13 at 06:16
6 Answers
I solved this issued by,
tabHost.getTabWidget().setDividerDrawable(null);
If your build target is Honeycomb onwards, you may use the following code also.
if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.HONEYCOMB) {
tabHost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
}

- 2,679
- 1
- 20
- 33
Before some times i have the same problem and my problem was resolved by setting padding to "0". I thinks, its taking some padding by default. So if you don't want space between your TabWidget, try the blow code.Please let me know if my solution will resolve your problem.
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
tabHost.getTabWidget().getChildAt(i).setPadding(0, 0, 0, 0);
}

- 3,603
- 3
- 31
- 47
In your main res/values/theme.xml
<style name="Theme.Main" parent="...">
...
<item name="android:actionBarTabBarStyle">@style/TabBar.Style</item>
...
</style>
in res/values/style.xml
<style name="TabBar.Style" parent="...">
...
<item name="android:showDividers">none</item>
...
</style>

- 93
- 1
- 8
Try this.
tabHost.getTabWidget().setDividerDrawable(R.drawable.empty);
and define drawable empty.xml.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<size
android:width="0px"
android:color="@android:color/black"
android:dashWidth="0px"
android:dashGap="0px" />
</shape>

- 12,332
- 10
- 44
- 62
I am assuming you are using your custom view for tab. To remove space between two tabs you should not set margin left and margin right of the view OR you may have set margin attribute which sets top, left, bottom, and right margins.
If your problem is the spacing inside the tab then do not apply padding to your view. If your problem is not solved yet please post your code.

- 99
- 6
Try Using the following:
tabHost.getTabWidget().setStripEnabled(false);
For more explantion you may refer this link
or do android:tabStripEnabled="false" in your XML

- 5,811
- 5
- 39
- 58
-
1Generally, it's a good idea to add a little explanation about what your code is doing/how it works or at least a link to the docs. – mgilson Dec 18 '13 at 06:22
-