Android在弹出菜单上更改文本颜色

时间:2017-07-30 08:06:15

标签: android popupmenu textcolor

在我的应用程序中,当我点击三个点按钮时,菜单项在白色背景上以白色文本颜色显示。我想将文字颜色改为黑色,但它不起作用。我一直在寻找解决方案,但没有一个能够解决问题。 这是我的代码:

styles.xml

<resources>
<style name="AppMaterialTheme" parent="SuperMaterialTheme">

</style>


<!-- Base application theme. -->
<style name="SuperMaterialTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_background</item>

</style>


<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textColorSecondary">@android:color/white</item>

</style>



<style name="PopupTheme" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:textColorPrimary">#000000</item>

</style>

Toolbar.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ToolbarTheme"
app:popupTheme="@style/PopupTheme"
>

哪里出错?提前致谢

1 个答案:

答案 0 :(得分:2)

您要求的菜单称为溢出菜单。您可以通过在style.xml中添加新样式来更改溢出菜单背景的颜色。

  <style name="OverflowMenu"
  parent="@android:style/Theme.Holo">
  <item name="android:popupMenuStyle">@style/MyOverflowMenu</item>
  <item name="android:itemTextAppearance">@style/TextAppearance</item>
  </style>
  <style name="MyOverflowMenu" 
  parent="@android:style/Widget.Holo.ListPopupWindow">
  <item name="android:popupBackground">@color/your_color</item> 
  </style>
  <style name="TextAppearance">
  <item name="android:textColor">@color/your_color</item>
  </style>