How do I remove the selected tab indicator from the TabWidget?

后端 未结 17 1257
猫巷女王i
猫巷女王i 2020-12-09 02:19

Here\'s what I\'d like to remove :

\"enter

How do I replace the indicator show

相关标签:
17条回答
  • 2020-12-09 02:52

    For TabLayout: Just Use app:tabIndicatorColor="@android:color/transparent"

    <android.support.design.widget.TabLayout
            android:id="@+id/profile_album_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="true"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:tabBackground="@drawable/tab_background"
            app:tabIndicatorColor="@android:color/transparent"
            app:tabPadding="@dimen/common_margin" />
    
    0 讨论(0)
  • 2020-12-09 02:52

    here what I use, since the tabIndicator.setSelectedTabIndicatorHeight(0); is depcrecated

    use tabIndicator.setSelectedTabIndicator(0);

    0 讨论(0)
  • 2020-12-09 02:57

    I looked for a long time to remove the ugly holo menu bar tried everything. accidentally used this code for another reason and it thank god removed it.

        for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {          
            tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#FF0000")); // unselected
            TextView tv = (TextView)tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); //Unselected Tabs
            tv.setTextColor(Color.parseColor("#ffffff"));
        }
    

    Source: Android tabhost change text color style

    0 讨论(0)
  • 2020-12-09 02:57

    You can simply use this method on your tablayout to hide the tab indicator.

    tabLayout.setSelectedTabIndicatorColor(Color.TRANSPARENT);
    
    0 讨论(0)
  • 2020-12-09 02:57

    Use this app:tabIndicator="@null"

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabIndicator="@null"
        app:tabMode="fixed" />
    
    0 讨论(0)
  • 2020-12-09 02:59

    Add this to your TabLayout XML:

    app:tabIndicator="@null"
    
    0 讨论(0)
提交回复
热议问题