Disable Material Ripple on Tablayout

喜夏-厌秋 提交于 2019-12-21 07:22:17

问题


I am trying to remove the Material Ripple Effect on my TabLayout's Tabs.

I am wondering if it is possible to do this?

Any ideas please?

I have tried setting the stateListAnimator to null but it still does not work

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stateListAnimator="@null"/>

回答1:


app:tabBackground does not work in my case.

This is my solution:

tabLayout.setTabRippleColor(null);



回答2:


Try to change the background, for example, use the transparent color of android.

 <android.support.design.widget.TabLayout
    android:layout_width="match_parent"
    android:layout_below="@id/toolbar"
    android:layout_height="70dip"
    app:tabBackground = "@android:color/transparent"
    app:tabMode="fixed" />



回答3:


Add this line to TabLayout in XML: app:tabRippleColor="@null"




回答4:


Clean code

tabLayout.setTabRippleColorResource(android.R.color.transparent);


来源:https://stackoverflow.com/questions/34585815/disable-material-ripple-on-tablayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!