2013-10-14 68 views
1

我想刪除標籤欄底部顯示的默認線。我試過如下:刪除標籤欄的底線

android:tabStripEnabled="false" 
tabHost.getTabWidget.setStripEnabled(false); 

也試過包裝在LinearLayout中對這個question

如何刪除該行的建議?

回答

1

我使用自定義視圖從標籤欄中刪除行。爲標籤視圖

自定義佈局:

<ImageView 
     android:id="@+id/tab_icon" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:layout_gravity="center" 
     android:contentDescription="@string/tab_desc" 
     android:gravity="center" /> 

</LinearLayout> 

設置選項卡視圖:

private void setUpTabs() { 
    TabSpec spec0 = tabHost.newTabSpec("Tab"); 
    spec0.setContent(R.id.tab_list); 
    spec0.setIndicator(tabView(R.drawable.image)); 
    tabHost.addTab(spec0); 
} 


// Return view for tab 
private View tabView(int drawableId) { 
    View view = LayoutInflater.from(this).inflate(R.layout.tab_image, 
           tabHost.getTabWidget(), false); 
    ImageView imageView = (ImageView) view.findViewById(R.id.tab_icon); 
    imageView.setImageResource(drawableId); 
    return view; 
} 
0

我刪除它使用

// Create Child Tab1 
    mTabHost.addTab(mTabHost.newTabSpec("child1").setIndicator("your text",getResources().getDrawable(R.drawable.your_image)), 
      yourclass.class, null); 

mTabHost.getTabWidget().getChildAt(0).setBackgroundColor(getResources().getColor(R.color.your background color)); 
    mTabHost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.your_image); 

我設置背景顏色,然後用藍線自動消失了上面的代碼中設置選項卡上的圖像,希望這對您有所幫助。

+0

我已經有了tabWidget的背景圖片。設置背景顏色將重疊圖像。 – Geek

+0

你有沒有試過設置?當你設置背景顏色時,它隱藏了那條藍線。 –

+0

是的,我做過。但是這也隱藏了圖像。 – Geek

0

使用這種代碼,並從tabhost除去線底部

android:tabStripEnabled="true" 
tabHost.getTabWidget.setStripEnabled(true);