[英]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?
该图像应与屏幕上出现的标签栏文本相同。请帮助我如何制作自定义标签栏图像?
Check out this post: 看看这个帖子:
How to customize android tabs or background change? 如何自定义Android标签或背景更改?
You can simply use xml layout as tab content. 您可以简单地使用xml布局作为选项卡内容。
EDIT: 编辑:
When You use ActionBar.Tab check out this ones: 当您使用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-actionbar/ 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.