我使用MaterialComponents.DayNight主题在我的应用程序。在白天模式,工具栏文字颜色为黑色。但是,当我切换到夜间模式的工具栏文本颜色为保持黑色,所以它不再是不可见的。
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
我要更改的工具栏文本颜色为白色夜间模式。我怎样才能做到这一点?
在我看来,你应该设置noActionbar的风格和设计新的工具栏和自定义
将此条目添加到您的主题:
<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/colorOnBackground
在Material Components library可用。如果你没有使用,你应该能够改用?android:attr/textColorPrimary
。