tablayout设置点击tab时的背景色

tabLayout.setTabRippleColor(ColorStateList.valueOf(getResources().getColor(R.color.color_transparent)));

//或者可以从xml中修改:
app:tabRippleColor="@color/color_transparent"

源码解释的意思

 /**
   * Sets the ripple color for this TabLayout.//修改布局的涟漪颜色
   *
   * 

When running on devices with KitKat or below, we draw this color as a filled overlay rather * than a ripple. * * @param color color (or ColorStateList) to use for the ripple * @attr ref com.google.android.material.R.styleable#TabLayout_tabRippleColor * @see #getTabRippleColor() */

注:仅以记录学习使用,如有错误,欢迎指出,互相学习

你可能感兴趣的:(tablayout设置点击tab时的背景色)