简体   繁体   English

如何使用Android在标签中心设置标签栏图像?

[英]how to set tab bar image in center of tab using android?

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. 这是我的代码。我是新手,有人可以帮我如何在中心显示imageIcon,就像测试在中心出现一样,请让我知道如何使用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);
            }
    }

目前的输出

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? 该图像应与屏幕上出现的标签栏文本相同。请帮助我如何制作自定义标签栏图像?

文字标签栏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM