Problem with custom tabs in android
Anyone know What image to I need to include to get rid of the small silver line at the bottom of the dark red tab in the picture?
This is how I'm changing the tab background:
public void onCreate (Bundle savedInstanceState)
{
...
setTabTheme();
tabHost.setOnTabChangedListener (otc);
...
}
// handler for tab changes to make sure our images are loaded
OnTabChangeListener otc = new OnTabChangeListener()
{
@Override
public void onTabChanged (String tabId)
{
setTabTheme();
}
};
private void setTabTheme()
{
tabHost = getTabHost();
TabWidget twid = tabHost.getTabWidget();
// set tab color
for(int i=0; i < tabHost.getTabWidget().getChildCount(); i++)
{
// unselected icon
Drawable tabd = (Drawable) getResources ().getDrawable (R.drawable.tabsel_dkred_big_9);
tabHost.getTabWidget().getChildAt(i).setBackgroundDrawable (tabd);
// need to figure out which one to make gray text...
Log.d (TAG, "this widget focused : " + twid.isFocused ());
// tab text
RelativeLayout rLayout = (RelativeLayout) twid.getChildAt(i);
if (rLayout.getChildCount () > 0)
{
TextView tv = ((TextView) rLayout.getChildAt(1));
tv.setTextColor (Color.WHITE);
// refer to res/style for text appearance
tv.setTextAppearance(getBaseContext (), R.开发者_运维技巧style.CustomText);
Log.d (TAG, "text is " + tv.getText ().toString ());
}
}
// set selected tab
Drawable tabd = (Drawable) getResources ().getDrawable (R.drawable.tabsel_red_big_9);
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundDrawable (tabd);
}
精彩评论