如何删除选项卡下的默认栏

时间:2014-08-18 12:50:39

标签: java android xml

我一直在尝试自定义应用的标签栏。除了默认蓝色细线显示在我的自定义可绘制标签上方的部分外,我几乎所有工作都在工作。 我将附上截图和xml样式。

TabBar

  1. styles.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <!-- Custom ActionBar -->
            <item name="android:actionBarStyle">@style/MyActionBar</item>
            <item name="android:actionMenuTextColor">@color/gray</item>
    
            <item name="android:actionBarTabStyle">@style/MyActionBar.TabStyle</item>
            <item name="android:actionBarTabTextStyle">@style/MyActionBar.TabText</item>
        </style>
    
        <!-- Custom ActionBar -->
        <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
            <item name="android:background">@color/white</item>
            <item name="android:backgroundStacked">@color/white</item>
        </style>
    
        <style name="MyActionBar.TitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
            <item name="android:textColor">@color/primary</item>
        </style>
    
        <style name="MyActionBar.TabStyle" parent="@style/Widget.AppCompat.ActionBar.TabView">
            <item name="android:background">@drawable/tab_indicator_myactionbar</item>
        </style>
    
        <style name="MyActionBar.TabText" parent="@style/Widget.AppCompat.ActionBar">
            <item name="android:textColor">@color/gray</item>
        </style>
    
    </resources>
    
  2. 抽拉/ tab_indicator_myactionbar.xml

    <?xml version="1.0" encoding="utf-8"?>
    
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
        <!-- Non focused -->
        <item
            android:state_focused="false"
            android:state_selected="false"
            android:state_pressed="false"
            android:drawable="@android:color/transparent" />
    
        <item
            android:state_focused="false"
            android:state_selected="true"
            android:state_pressed="false"
            android:drawable="@drawable/tab_selected_myactionbar" />
    
       <!-- Focused -->
       <item
           android:state_focused="true"
           android:state_selected="false"
           android:state_pressed="false"
           android:drawable="@drawable/tab_focused_unselected_myactionbar" />
    
       <item
           android:state_focused="true"
           android:state_selected="true"
           android:state_pressed="false"
           android:drawable="@drawable/tab_focused_selected_myactionbar" />
    
       <!-- Pressed -->
       <!--    Non focused -->
       <item
           android:state_focused="false"
           android:state_selected="false"
           android:state_pressed="true"
           android:drawable="@drawable/tab_unselected_pressed_myactionbar" />
    
       <item
           android:state_focused="false"
           android:state_selected="true"
           android:state_pressed="true"
           android:drawable="@drawable/tab_selected_pressed_myactionbar" />
    
       <!--    Focused -->
       <item
           android:state_focused="true"
           android:state_selected="false"
           android:state_pressed="true"
           android:drawable="@drawable/tab_unselected_pressed_myactionbar" />
    
       <item
           android:state_focused="true"
           android:state_selected="true"
           android:state_pressed="true"
           android:drawable="@drawable/tab_selected_pressed_myactionbar" />
    
    </selector>
    

0 个答案:

没有答案
相关问题