android 中自定义选项卡的问题
有人知道我需要包含什么图像才能消除图片中深红色选项卡底部的小银线吗?
这就是我更改选项卡背景的方式:
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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论