【问题标题】:changing overflow menu toolbar text and background color更改溢出菜单工具栏文本和背景颜色
【发布时间】:2016-01-23 12:41:00
【问题描述】:

这是我的工具栏

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ToolbarTheme"
    popupTheme="@style/ToolbarStylepopuptheme" />

还有我的 style.xml

<style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:background">@color/colorPrimary</item>
    <item name="android:textColorPrimary">#ffffff</item>
    <item name="actionMenuTextColor">#ffffff</item>
</style>

<style name="ToolbarStylepopuptheme" >
    <item name="android:colorBackground">@android:color/darker_gray</item>
    <item name="android:textColor">#ffff55</item>
</style>

我已经在互联网上查了很多东西,似乎没有什么对我有用。我的应用支持 API 级别 16 及以上。

【问题讨论】:

  • 如果我将 xml 中的 popupTheme="@style/ToolbarStylepopuptheme" 更改为 app:popupTheme="@style/ToolbarStylepopuptheme" 文本颜色会改变但背景没有改变
  • 与 'app:' 一起使用并将父级分配给与上述样式相同的样式 'ToolbarStylepopuptheme'

标签: android toolbar


【解决方案1】:

尝试使用:

<item name="android:popupBackground">@android:color/white</item>

或者,添加这个:parent="@android:style/Widget.PopupMenu" 用你的代码试试吧。

最后:

<style name="ToolbarStylepopuptheme" parent="@android:style/Widget.PopupMenu">

我忘了说,我的错!将此(app)添加到您的工具栏

app:popupTheme="@style/ToolbarStylepopuptheme"

【讨论】:

  • 我正在 android 5.0 上测试它,如果这可能会有所不同
  • 耶稣! :),看看这个:i.imgur.com/QTeruLO.png5.1.1 上工作过。你说,5?表示21 api?
  • 是的,我使用的是普通风格
  • 对不起,我没有看到你正在使用 android 请再次检查我的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-25
  • 1970-01-01
  • 2015-05-19
  • 1970-01-01
  • 1970-01-01
  • 2020-09-30
相关资源
最近更新 更多