The following shows how to change the color and the height of the standard Android tabs.
In TabActivity.onCreate():
final TabHost tabHost = getTabHost();
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener()
@Override
public void onTabChanged(String tabId) {
setTabColors(tabHost);
}
});
...
// This tab activity is always launched via an intent which
// passes the tag of the tab to start on in a String extra
// with key "tab_name". Set the current tab before initializing
// the colors.
tabHost.setCurrentTabByTag(getIntent().getStringEx tra("tab_name"));
setTabColors(tabHost);
As a method in your TabActivity:
private void setTabColors(final TabHost tabHost) {
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
tabHost.getTabWidget().getChildAt(i).getLayoutPara ms().height = 40;
tabHost.getTabWidget().getChildAt(i).setBackground Color(Color.LTGRAY);
}
tabHost.getTabWidget().getChildAt(tabHost.getCurre ntTab())
.setBackgroundColor(Color.parseColor(Color.RED));
}
Quote:
Originally Posted by deep007.mm
Hi Everybody,
I am using TabWidget. It comes with the default grey background color. Is it possible to change this? If it is then please tell me how can I do this??
Thanks
Deepak
|