Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable click effect on TabLayout?

How to disable this click effect?

enter image description here

I tried to add these to Activity's theme but not working

<item name="tabIndicatorColor">@android:color/transparent</item>
<item name="tabBackground">@android:color/transparent</item>
<item name="tabTextAppearance">@android:color/transparent</item>
<item name="tabSelectedTextColor">@android:color/transparent</item>

I also tried to use the theme in TabLayout directly but the app will crash

And also tried android:stateListAnimator, but still not working

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    style="@style/AppTheme"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:stateListAnimator="@null">
like image 725
CL So Avatar asked Jul 27 '18 19:07

CL So


2 Answers

Use app:tabRippleColor="@null"

<android.support.design.widget.TabLayout
        android:id="@+id/homeTabLayout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/custom_tab_layout_height"
        android:layout_alignParentBottom="true"
        android:background="@color/white"
        android:tabStripEnabled="true"
        app:tabBackground="@color/white"
        app:tabGravity="fill"
        app:tabIndicatorHeight="0dp"
        app:tabMode="fixed"
        app:tabPaddingEnd="-1dp"
        app:tabPaddingStart="-1dp"
        app:tabRippleColor="@null" />

This works for me.

like image 131
Velayutham M Avatar answered Sep 22 '22 14:09

Velayutham M


Do this:

app:tabRippleColor="@null"

This basically disables the ripple background resource.

like image 45
Abhishek A Udupa Avatar answered Sep 22 '22 14:09

Abhishek A Udupa