gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 09:33:20 25 4
gpt4 key购买 nike

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

样式.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>

工具栏.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"
>

错在哪里?提前致谢

最佳答案

您要求的菜单称为溢出菜单。您可以通过在 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>

关于Android在弹出菜单上更改文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45397714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com