android中自定义标签的问题

时间:2011-03-16 13:36:03

标签: android tabs

任何人都知道我需要包含什么图像才能摆脱图片中深红色标签底部的小银线?

tabs with silver bottom border

这就是我改变标签背景的方式:

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); 
}

0 个答案:

没有答案