Android的弹出式菜单文本颜色(AppCompat)弹出式、菜单、文本、颜色

由网友(俄為自己帶盐)分享简介:我需要更改popuo菜单的文本颜色,但我没有找到任何办法做到这一点,我可以改变popmenu的背景,但没有文字,我编辑style.xml以这种方式:<样式名称=AppBaseTheme父=Theme.AppCompat.Light><! - API 14主题自定义可以去这里。 - ><项...

我需要更改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应对当前的样式。

Android移动开发技术文章 手机开发

您必须使用:

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.

阅读全文

相关推荐

最新文章