如何改变从MaterialComponents.DayNight主题栏的文字颜色?

问题描述 投票:1回答:1

我使用MaterialComponents.DayNight主题在我的应用程序。在白天模式,工具栏文字颜色为黑色。但是,当我切换到夜间模式的工具栏文本颜色为保持黑色,所以它不再是不可见的。

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

我要更改的工具栏文本颜色为白色夜间模式。我怎样才能做到这一点?

android material-design android-toolbar android-styles
1个回答
2
投票

在我看来,你应该设置noActionbar的风格和设计新的工具栏和自定义


2
投票

将此条目添加到您的主题:

<item name="android:itemTextAppearance">@style/PopupMenuTextAppearance</item>

在此之后,添加相应的风格,以styles.xml

<style name="PopupMenuTextAppearance" parent="TextAppearance.AppCompat.Menu">
    <item name="android:textColor">?attr/colorOnBackground</item>
</style>

?attr/colorOnBackgroundMaterial Components library可用。如果你没有使用,你应该能够改用?android:attr/textColorPrimary

© www.soinside.com 2019 - 2024. All rights reserved.