[英]how to set tab bar image in center of tab 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);
}
}
最终的标签栏图像应显示在标签栏的蓝线上方和中间。 该图像应与屏幕上出现的标签栏文本相同。请帮助我如何制作自定义标签栏图像?
看看这个帖子:
您可以简单地使用xml布局作为选项卡内容。
编辑:
当您使用ActionBar.Tab时,请检查以下内容:
http://developer.android.com/reference/android/app/ActionBar.Tab.html#setCustomView(int) http://www.lucazanini.eu/2012/android/customizing-the-labels-of-an-动作栏/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.