本文介绍了Android的弹出式菜单文本颜色(AppCompat)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改popuo菜单的文本颜色,但我没有找到任何办法做到这一点,我可以改变popmenu的背景,但没有文字,我编辑style.xml以这种方式:

 <样式名称=AppBaseTheme父=Theme.AppCompat.Light>
    <! -  API 14主题自定义可以去这里。 - >

    <项目名称=popupMenuStyle> @风格/ MyPopupMenu< /项目>
    <项目名称=机器人:textAppearanceLargePopupMenu> @风格/ myPopupMenuTextAppearanceLarge< /项目>
    <项目名称=机器人:textAppearanceSmallPopupMenu> @风格/ myPopupMenuTextAppearanceSmall< /项目>
< /风格>

<样式名称=MyPopupMenu父=@风格/ Widget.AppCompat.PopupMenu>
    <项目名称=机器人:popupBackground>#0F213F< /项目>
< /风格>

<样式名称=myPopupMenuTextAppearanceSmall父=@风格/ TextAppearance.AppCompat.Base.Widget.PopupMenu.Small>
    <项目名称=机器人:文字颜色>#FFFFFF< /项目>
< /风格>

<样式名称=myPopupMenuTextAppearanceLarge父=@风格/ TextAppearance.AppCompat.Base.Widget.PopupMenu.Large>
    <项目名称=机器人:文字颜色>#FFFFFF< /项目>
< /风格>
 

在哪里错了吗?

解决方案

 &LT;项目name="textAppearanceLargePopupMenu">@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large</item>
&LT;项目name="textAppearanceSmallPopupMenu">@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small</item>
 

我认为你正在使用TextAppearance.AppCompat.Base.Widget.PopupMenu。以下是错误,您使用的是另一位家长说doesn't应对当前的样式。

您必须使用:

TextAppearance.AppCompat.Light.Widget.PopupMenu。

I need to change text color of a popuo menu but I don't find any way for do this, I can change background of popmenu but not the text, I edit the style.xml in this way:

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!-- API 14 theme customizations can go here. -->

    <item name="popupMenuStyle">@style/MyPopupMenu</item>
    <item name="android:textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item>
    <item name="android:textAppearanceSmallPopupMenu">@style/myPopupMenuTextAppearanceSmall</item>
</style>

<style name="MyPopupMenu" parent="@style/Widget.AppCompat.PopupMenu">
    <item name="android:popupBackground">#0F213F</item>
</style>

<style name="myPopupMenuTextAppearanceSmall" parent="@style/TextAppearance.AppCompat.Base.Widget.PopupMenu.Small">
    <item name="android:textColor">#ffffff</item>
</style>

<style name="myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Base.Widget.PopupMenu.Large">
    <item name="android:textColor">#ffffff</item>
</style>

where is the mistake?

解决方案
<item name="textAppearanceLargePopupMenu">@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large</item>
<item name="textAppearanceSmallPopupMenu">@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small</item>

I think that you are using TextAppearance.AppCompat.Base.Widget.PopupMenu. Here is the error, you are using another parent that doesn´t response the current style.

You have to use:

TextAppearance.AppCompat.Light.Widget.PopupMenu.

这篇关于Android的弹出式菜单文本颜色(AppCompat)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:13