【问题标题】:Change the text color of the popup menu更改弹出菜单的文本颜色
【发布时间】:2015-03-06 05:25:04
【问题描述】:

我正在使用 Theme.AppCompat.Light.NoActionBar 主题。我正在为弹出菜单获得白色背景,并且菜单项的颜色是白色,使其不可见。我尝试了许多解决方案都没有成功。

这是我的 style.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:actionMenuTextColor">#000000</item>
    <item name="android:textColorPrimary">@color/white</item>
    <item name="android:textColorSecondary">@color/white</item>
    <item name="android:popupMenuStyle">@style/PopupMenu</item>
    <item name="android:textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item>
    <item name="android:textAppearanceSmallPopupMenu">@style/myPopupMenuTextAppearanceSmall</item>
    <!-- Customize your theme here. -->
</style>

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
    <item name="android:popupBackground">@android:color/white</item>
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">12sp</item>
</style>

<style name="myPopupMenuTextAppearanceSmall" parent="@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small" tools:ignore="NewApi">
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">15sp</item>
</style>

<style name="myPopupMenuTextAppearanceLarge" parent="@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large" tools:ignore="NewApi">
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">25sp</item>
</style>

这是工具栏

<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/toolbar"
    android:elevation="8dp"
    app:theme="@style/AppTheme"
    app:title="Troll Cricket" />

【问题讨论】:

    标签: android


    【解决方案1】:

    将这些行添加到您的 Toolbar.xml 文件中。

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

    这将允许您拥有一个深色工具栏和浅色主题溢出菜单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多