更改溢出菜单工具栏文本和背景颜色
changing overflow menu toolbar text and background color
这是我的工具栏
<?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 及以上。
尝试使用:
<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"
这是我的工具栏
<?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 及以上。
尝试使用:
<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"