小编Mag*_*gCZ的帖子

继承 Theme.AppCompat.DayNight 后更改 ActionBar 文本颜色

我正在实现对暗模式的支持。但是在我将 Theme parent 更改为Theme.AppCompat.DayNight 之后,Action Bar 中的文本是黑色的(白天模式下为黑色,黑暗模式下为白色)。我希望文本始终为白色。我试图在styles.xml (values and values-night) 中改变文本颜色

<style name="AppTheme" parent="Theme.AppCompat.DayNight">
  <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
</style>

<style name="MyActionBarStyle" parent="Theme.AppCompat.DayNight.DarkActionBar">
  <item name="android:titleTextStyle">@style/MyActionBarTitleTextStyle</item>
</style>

<style name="MyActionBarTitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
  <item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但它不起作用。ActionBar 中的标题文本颜色仍然是黑色。

android android-appcompat android-actionbar android-darkmode

6
推荐指数
1
解决办法
2812
查看次数