5

我在我当前的 android 应用程序中使用 Theme.Holo。

在此处输入图像描述

以上是我当前主题的溢出 UI。

我想将溢出菜单的背景颜色自定义为 RGB(245、243、239),将字体颜色自定义为 RGB(64、64、64)。

以下是我正在使用的 style.xml

<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/CustomActivityTheme.ActionBar</item>
    <item name="android:actionMenuTextColor">#000000</item>
    <item name="android:divider">@drawable/action_bar_div</item>
    <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
</style>

<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow">
    <item name="android:src">@drawable/overflow</item>
</style>

<style name="CustomActivityTheme.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/actionbar_bg</item>
    <item name="android:titleTextStyle">@style/CustomActivityTheme.ActionBar.Text</item>
    <item name="android:subtitleTextStyle">@style/CustomActivityTheme.ActionBar.Text</item>
</style>

<style name="CustomActivityTheme.ActionBar.Text" parent="@android:style/TextAppearance">
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">16sp</item>
</style>

<style name="activated" parent="android:Theme.Holo">
    <item name="android:background">?android:attr/activatedBackgroundIndicator</item>
</style>

<!-- style for removing the floating dialog -->
<style name="CustomDialogTheme">
    <item name="android:windowIsFloating">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

<!-- style for transparent image resource  activity -->

<style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:windowAnimationStyle">@style/MyAnimation.Window</item>
</style>

<!-- Animations for a non-full-screen window or activity. -->
<style name="MyAnimation.Window" parent="@android:style/Animation.Dialog">
    <item name="android:windowEnterAnimation">@anim/grow_from_middle</item>
    <item name="android:windowExitAnimation">@anim/shrink_to_middle</item>
</style>

<!-- style for transparent audio and video resource  activity -->

<style name="Theme.Transparent_Player" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:windowAnimationStyle">@style/MyPlayerAnimation.Window</item>
</style>

<!-- Animations for a non-full-screen window or activity. -->
<style name="MyPlayerAnimation.Window" parent="@android:style/Animation.Dialog">
    <item name="android:windowEnterAnimation">@anim/grow_from_action_bar</item>
    <item name="android:windowExitAnimation">@anim/shrink_to_action_bar</item>
</style>

在上面的代码中,如何自定义主题以将溢出菜单的背景颜色与 RGB(245、243、239)匹配,并将字体颜色与 RGB(64、64、64)匹配?

提前致谢..

4

3 回答 3

5

要更改文本颜色,您可以使用:

<item name="android:textAppearanceLargePopupMenu" >@style/m_textAppearanceLargePopupMenu</item>

<item name="android:textAppearanceSmallPopupMenu" >@style/m_textAppearanceSmallPopupMenu</item>

 <style name="m_textAppearanceLargePopupMenu" parent="@android:style/TextAppearance.Holo.Widget.PopupMenu.Large">
        <item name="android:textColor">#FFF</item>
    </style>

    <style name="m_textAppearanceSmallPopupMenu" parent="@android:style/TextAppearance.Holo.Widget.PopupMenu.Small">
        <item name="android:textColor">#FFF</item>
    </style>

这会将弹出菜单文本颜色更改为白色

于 2013-12-08T20:51:00.233 回答
3

试试这个:

<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
    ...
    <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
    ...
</style>

<style name="MyPopupMenu" parent="android:style/Widget.Holo.Light.ListPopupWindow">
    <item name="android:background">#f5fdef</item> 
</style>

我在这篇文章中找到了

于 2013-01-07T09:34:27.047 回答
0
<style name="MyActionBar3" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="android:background">@color/ActionBarBackground</item>         
</style>

<style name="MyActionBarDropDownStyle" parent="">
    <item name="android:background">#00FF00</item>        
    <item name="android:divider">#ff0000</item>
    <item name="android:dividerHeight">1dp</item> 
    <item name="android:textColor">#FFFFFF</item>     
    <item name="android:textSize">10sp</item>
</style>

<style name="MyTextStyle" parent="@style/Widget.AppCompat.Light.Base.ListPopupWindow">
    <item name="android:popupBackground">#FF0000</item>        
</style>

将样式应用于 android:textAppearanceLargePopupMenu" 项目的属性

于 2015-03-29T16:12:09.323 回答