选定选项卡下划线的TabLayout颜色

asc*_*sco 55 android android-layout

如何更改新TabLayout上所选选项卡下划线的颜色?该PagerTabStrip有一个方法setTabIndicatorColor(int color),TabLayout似乎不具有这样的方法.

在此输入图像描述

Jar*_*ows 170

使用app:tabIndicatorColor.

例:

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabIndicatorColor="@android:color/white" />
Run Code Online (Sandbox Code Playgroud)

确保你有这个namespace:xmlns:app="http://schemas.android.com/apk/res-auto"

文档: https ://developer.android.com/reference/android/support/design/widget/TabLayout.html#attr_android.support.design : tabIndicatorColor.

  • “ app:tabIndicatorColor”有效。但是我找不到官方文档提到它。 (2认同)
  • 在Android开发方面,有很多未记录的事情. (2认同)