0

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;
}
5
  • Have you tried to add space in String?
    – Abx
    Commented Dec 27, 2012 at 6:38
  • try to set margin for it. Commented Dec 27, 2012 at 6:51
  • Edited my post.how can set margin for selector?
    – iShare
    Commented Dec 27, 2012 at 7:09
  • adding space to string not allowed in xml abhilash
    – iShare
    Commented Dec 27, 2012 at 7:10
  • @iShare: I think I can use space in String,<string name="stringname"> Home</string>
    – Abx
    Commented Dec 27, 2012 at 10:14

2 Answers 2

5

Try this, :)

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

Reduce the size of width of home_icon image.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.