无法在android中更改Tabhost的背景色
最近,我制作了一个利用Tabhost的简单应用程序。 但是,我无法设置它的颜色。我已经在下面设置了示例代码。如何才能将颜色添加到当前代码中?如果我能得到小费或帮助,那将是一个很大的帮助无法在android中更改Tabhost的背景色,android,android-tabhost,Android,Android Tabhost,最近,我制作了一个利用Tabhost的简单应用程序。 但是,我无法设置它的颜色。我已经在下面设置了示例代码。如何才能将颜色添加到当前代码中?如果我能得到小费或帮助,那将是一个很大的帮助 Resources res = getResources(); TabHost tabHost = getTabHost(); TabSpec spec; Intent intent; //tabHost.getTabWidget().get
Resources res = getResources();
TabHost tabHost = getTabHost();
TabSpec spec;
Intent intent;
//tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#C0392B"));
intent = new Intent().setClass(this, SecondActivity.class);
spec = tabHost.newTabSpec("Second Activity").setIndicator(res.getString(R.string.act_second), res.getDrawable(R.drawable.ic_tab)).setContent(intent);
tabHost.addTab(spec);
我在我的
tabChanged
方法中设置tabHost
的颜色,如下所示:
for( int i=0;i<mTabHost.getTabWidget().getChildCount();i++)
{
mTabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
}
mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#4E4E9C"));
for(int i=0;i如果当前选项卡或其他选项卡未被选中,您想为它们指定颜色吗?好的,我想将颜色设置为当前选项卡和所选选项卡。谢谢!我会尝试!