【问题标题】:Android Light AppTheme with Dark ActionBar (AppCompat)Android Light AppTheme with Dark ActionBar (AppCompat)
【发布时间】:2016-02-11 11:58:49
【问题描述】:

我有应用程序主题Theme.AppCompat.Light.NoActionBar,它为我的应用程序提供了浅色主题,所以Dialogs 等上的文本是深色的。我还希望我的Toolbar 有深色背景和浅色前景,所以我把这些写给Toolbar

app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"

问题:这会使 Toolbar 变暗,文字在 Lollipop 上变为白色,但在 KitKat 上不起作用:

棒棒糖:


奇巧

问题:如何使用我当前的主题Theme.AppCompat.Light.NoActionBar 在 KitKat 上制作带有浅色内容的深色工具栏?

【问题讨论】:

  • 你在使用styles.xml v21吗?
  • @4k3R 不,只是 styles.xml
  • 您找到解决方案了吗?我目前正在解决同样的问题,但没有成功。
  • @shelll 我不记得了,尝试使用android:themeapp:popupTheme
  • 问题是我在Activity 中的setContentView(...) 之后调用了super.onCreate(...)。这是对第 3 方库的特殊需求 :(

标签: android android-appcompat android-theme android-toolbar android-styles


【解决方案1】:

试试这个:

<style name="MyToolbarStyle" parent="Theme.AppCompat.Light">
    <!-- Used to for the title of the Toolbar -->
    <item name="android:textColorPrimary">#fff</item>
    <!-- Used to for the title of the Toolbar when parent is Theme.AppCompat.Light -->
    <item name="android:textColorPrimaryInverse">#fff</item>
    <!-- Used to color the text of the action menu icons -->
    <item name="android:textColorSecondary">#fff</item>
    <!-- Used to color the overflow menu icon -->
    <item name="actionMenuTextColor">#fff</item>
    <!-- Color of the Toolbar -->
    <item name="android:background">#455a64</item>
</style>

看看这篇文章:

Android Theme.AppCompat.Light with Dark Toolbar (for light text)

【讨论】:

  • 是的,我以前读过这个,这是为了改变文本颜色,这对我不起作用不知道为什么)我的目标是改变图标颜色
猜你喜欢
  • 1970-01-01
  • 2020-10-11
  • 2014-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-04
  • 1970-01-01
相关资源
最近更新 更多