How to remove TabItem indicator bottom padding?

Viewed 3385

How to remove bottom padding of TabItem or its indicator, so that it would appear totally on the bottom of toolbar?

enter image description here

My xml layout

<android.support.v7.widget.Toolbar
        android:id="@+id/menu_fragment_toolbar"
        android:layout_width="match_parent"
        android:layout_height="58dp"
        android:background="@color/app_font_dark"
        android:padding="0dp"
        android:popupTheme="@style/AppTheme.AppBarOverlay"
        app:contentInsetStart="0dp"
        >

        <android.support.design.widget.TabLayout
            android:id="@+id/main_menu_tablayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:paddingEnd="0dp"
            android:paddingStart="0dp"
            app:tabIndicatorColor="@color/app_indicator_color"
            app:tabIndicatorHeight="4dp"
            app:tabMode="scrollable"
            app:tabPaddingEnd="30dp"
            app:tabPaddingStart="30dp"
            app:tabTextAppearance="@style/TabTextStyle"
            />
</android.support.v7.widget.Toolbar>

I have tried setting bottom margin and padding of Toolbar and TabLayout to 0dp but it doesn't seem to take effect. I'm using support library v26.0.0-alpha1 and device with API 25. I'm adding TabItems dynamically by calling

tabLayout.addTab(tabLayout.newTab().setText("Some long text"));

4 Answers

I have update to androidx, change height like this android:layout_height="?attr/actionBarSize"

My Code is below

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tl_local_category"
    android:layout_width="0dp"
    android:background="?attr/colorPrimary"
    android:layout_height="?attr/actionBarSize"
    app:tabTextAppearance="@style/TabTextAppearance"
    app:tabSelectedTextColor="@color/white"
    app:tabTextColor="@color/tab_text"
    app:layout_constraintEnd_toEndOf="parent"
    app:tabIndicatorColor="@android:color/white"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">
</com.google.android.material.tabs.TabLayout>

enter image description here

Related