1

here is my code .I am newbie can someone please help me how can i display imageIcon in center just like test appear in center please let me know how can i customize tab bar image using android.

protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                ActionBar bar = getActionBar();
                  bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
            bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
            String headerName[] = {"Info","Location","Discipline","Summary","Status", "Plus"};
            //int headerName[]={R.drawable.info,R.drawable.location,R.drawable.discipline,R.drawable.summary,R.drawable.status, R.drawable.plus};
            Log.i("log ", "1");
            for (int i=0; i < headerName.length; i++) {

                    Tab tab = bar.newTab();                        
                   // tab.setText(headerName[i]);
                 tab.setIcon(R.drawable.info);

                    tab.setTabListener(this);
                    bar.addTab(tab);
                    Log.i("log ", "" +i);
            }
    }

present output

the final tab bar image should display above the Blue line of tab bar and as well as in center. the image should appear same as tab bar text appearing in screen please help me how can i make custom tab bar image?

text tab bar

nida
  • 656
  • 3
  • 16
  • 38

1 Answers1

0

Check out this post:

How to customize android tabs or background change?

You can simply use xml layout as tab content.

EDIT:
When You use ActionBar.Tab check out this ones:

http://developer.android.com/reference/android/app/ActionBar.Tab.html#setCustomView(int) http://www.lucazanini.eu/2012/android/customizing-the-labels-of-an-actionbar/

Community
  • 1
  • 1
Peter Moskala
  • 360
  • 1
  • 9
  • i am not using tabHOST i want to do by using ActionBar bar = getActionBar(); Tab tab = bar.newTab(); tab.setText(headerName[i]); // tab.setIcon(R.drawable.info); – nida Nov 22 '13 at 09:39
  • It should be easier than using tabhost. Did you try this: http://developer.android.com/reference/android/app/ActionBar.Tab.html#setCustomView(int) ? – Peter Moskala Nov 22 '13 at 14:28