7

enter image description here

I want this spacing between the tabs removed, How can this be achieved ?

Prateek
  • 3,923
  • 6
  • 41
  • 79
R KiranKumar
  • 825
  • 1
  • 8
  • 27

6 Answers6

7

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);
}
No_Rulz
  • 2,679
  • 1
  • 20
  • 33
4

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);
    }
Akanksha Rathore
  • 3,603
  • 3
  • 31
  • 47
3

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>
Mnio
  • 93
  • 1
  • 8
3

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>
Deniz
  • 12,332
  • 10
  • 44
  • 62
2

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.

2

Try Using the following:

tabHost.getTabWidget().setStripEnabled(false);

For more explantion you may refer this link

or do android:tabStripEnabled="false" in your XML

akshay
  • 5,811
  • 5
  • 39
  • 58
  • 1
    Generally, 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
  • Ohk, Thanx.. I have edited it. Please check it and let me know. – akshay Dec 18 '13 at 06:39