iShare
iShare

Reputation: 125

Space between ICON and TEXT in Tab control - Android

I am using compact tab for my app.

    TabHelper tabHelper = getTabHelper();

    CompatTab menuTab = tabHelper.newTab("menu");
    menuTab.setText(R.string.tab_section1);

    menuTab.setIcon(R.drawable.home_icon);
    menuTab.setTabListener(new InstantiatingTabListener(
            this, MenuFragment.class));
    tabHelper.addTab(menuTab);

I do have resource file code as follow

    <string name="tab_section1">Home</string>

Menu Tab renders properly but there is no SPACE between ICON and TEXT. How can I achieve it?

Icon and text "Map" is very close without space

Icon and text "Map" is very close without space

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" 
 android:drawable="@drawable/home_selected" />
<item android:drawable="@drawable/home" />
</selector>

My setText Methos

@Override
public CompatTab setText(int resId) {
    mText = mActivity.getResources().getText(resId);
    return this;
}

Upvotes: 0

Views: 2286

Answers (2)

No_Rulz
No_Rulz

Reputation: 2719

Try this, :)

menuTab.setText("\t"+"Home");

Upvotes: 5

Dhana
Dhana

Reputation: 554

Reduce the size of width of home_icon image.

Upvotes: 1

Related Questions