android - TabIndicatorColor not working in night theme.xml
问题描述
I am trying to set the tabIndicatorColor to a specified color depending on the device theme(That color in dark theme is white). The light theme works fine but in dark theme, the text in tabLayout is in white whereas the tabIndicatorColor does not turn white even though it is set to white. It shows a greyish color as the tabIndicatorColor.
night/themes.xml
<style name="Theme.News" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/darkGrey</item>
<item name="colorPrimaryVariant">@color/lightGrey</item>
<item name="colorOnPrimary">@color/white</item>
<item name="colorSurface">@color/lightGrey</item>
<item name="colorOnSurface">@color/white</item>
The tabLayout xml in activity_main.xml
<com.google.android.material.tabs.TabLayout
android:background="?attr/colorPrimary"
app:tabTextColor="?attr/colorSecondary"
app:tabSelectedTextColor="?attr/colorOnPrimary"
app:tabIndicatorColor="?attr/colorOnPrimary">
</com.google.android.material.tabs.TabLayout>
解决方案
推荐阅读
- javascript - Jquery将类添加到不同按钮上的div
- javascript - Javascript 控制台在折叠和展开时显示不同的值,并且与引用时不同
- python - 找不到 panda.tslib 模块
- c# - 如何使用 HTTP get 方法从数据库中请求数据?
- python - 即使我将目录下载到 nltk.data.path 的路径列表中,NLTK 也找不到路径
- python - 通过opencv Python检测图像中是否有灰色
- reactjs - React route,在 CoreUI 上使用具有不同 props/parameters 的相同组件
- laravel - Laravel:如何从数据库中设置复选框的值
- arrays - 在 Go 中,如何解组包含结构数组的字符串
- teradata - Teradata - 如何避免发生多次重新分配