2011-08-01 109 views
2

我有一個自定義選項卡指示器來製作我的選項卡。但是,我想刪除選項卡下方的底部邊框。單黑線和灰度陰影。我甚至不知道什麼是產生灰度漸變。它可能是TabWidget,FrameLayout或子項的LinearLayout。刪除灰度TabWidget邊框/邊緣

enter image description here

作爲參考,我已經試過setStripEnabled(假); 另一個潛在的困難是我以編程方式創建TabHost & TabWidget,而不是使用佈局文件。

回答

2

當我使用標籤時,我通常只是通過將android可見性設置爲消失來隱藏tabwidget標籤。

按鈕並將其添加到充當標籤按鈕像

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" 
     android:layout_height="fill_parent">  
     <FrameLayout android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" android:layout_height="0dip" 
      android:layout_weight="1.0"/> 
     <FrameLayout android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:visibility="gone"/> 
      <LinearLayout android:layout_width="fill_parent" 
       android:layout_height="64dip"> 
       <Button android:layout_height="fill_parent" android:layout_width="0dip" 
        android:layout_weight="1.0" 
        android:background="@drawable/ic_tab_artists" 
        android:id="@+id/artist_id" android:onClick="tabHandler"/> 
       <Button android:layout_height="fill_parent" android:layout_width="0dip" 
        android:layout_weight="1.0" 
        android:background="@drawable/ic_tab_artists" 
        android:id="@+id/album_id" android:onClick="tabHandler"/> 
       <Button android:layout_height="fill_parent" android:layout_width="0dip"  
        android:layout_weight="1.0" 
        android:background="@drawable/ic_tab_artists" 
        android:id="@+id/song_id" android:onClick="tabHandler"/> 
      </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 
</TabHost> 

,我添加一個按鈕單擊處理

public void tabHandler(View target){ 
    artistButton.setSelected(false); 
    albumButton.setSelected(false); 
    songButton.setSelected(false); 
    if(target.getId() == R.id.artist_id){ 
     tabHost.setCurrentTab(0); 
     artistButton.setSelected(true); 
    } else if(target.getId() == R.id.album_id){ 
     tabHost.setCurrentTab(1); 
     albumButton.setSelected(true); 
    } else if(target.getId() == R.id.song_id){ 
     tabHost.setCurrentTab(2); 
     songButton.setSelected(true); 
    } 
} 

這應該刪除所有行和灰度。