如何更改 TabWidget 底栏的颜色?我已成功更改选项卡背景颜色,但底部栏仍然是灰色/橙色,我在 Android 文档和源中找不到任何有关此的信息。谢谢。
问问题
11799 次
3 回答
1
看:
启用/禁用此行:
tabHost.getTabWidget().setStripEnabled(boolean);
为这条线在左边设置drawable:
tabHost.getTabWidget().setLeftStripDrawable(drawable);
为这条线在左边设置资源
tabHost.getTabWidget().setLeftStripDrawable(resId);
为这条线在右边设置drawable:
tabHost.getTabWidget().setRightStripDrawable(drawable);
为这一行设置资源:
tabHost.getTabWidget().setRightStripDrawable(resId);
于 2012-02-10T05:29:09.973 回答
0
我猜“底栏”是指分隔选项卡和内容的可选水平线。查看TabWidget API 文档中描述的各种 tabStrip 属性。您可以为条带的左右部分设置不同的可绘制对象。
于 2011-05-31T02:16:26.017 回答
0
public void setTabColor(TabHost tabhost) {
int totalTabs = tabhost.getTabWidget().getChildCount();
for(int i=0;i<totalTabs;i++) {
if(tabHost.getTabWidget().getChildAt(i).isSelected()){
tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_selector); //selector xml for selected
tabHost.getTabWidget().setStripEnabled(true);
tabHost.getTabWidget().setRightStripDrawable(R.drawable.tab_strip_thin);
tabHost.getTabWidget().setLeftStripDrawable(R.drawable.tab_strip_thin);
}
}
}
于 2012-10-10T12:25:40.457 回答