6

我想自定义我的应用程序并且我已经应用了一个主题,但选项菜单似乎没有应用我的主题。

我希望我的文本颜色为白色,背景为黑色,突出显示/选定的菜单项为黄色。这是我的主题.xml:

<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionMenuTextColor">@color/application_color5</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>
    <item name="android:selectableItemBackground">@drawable/icone_barratopo_selector</item>
    <item name="android:actionBarItemBackground">@drawable/icone_barratopo_selector</item>
    <item name="android:selectableItemBackground">@drawable/icone_barratopo_selector</item>
    <!-- Panel attributes -->
    <!-- <item name="android:panelBackground">@drawable/selectable_background</item> --


    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="actionMenuTextColor">@color/application_color5</item>
    <item name="actionBarTabStyle">@style/MyActionBarTabs</item>
    <item name="selectableItemBackground">@drawable/icone_barratopo_selector</item>
    <item name="actionBarItemBackground">@drawable/icone_barratopo_selector</item>
    <item name="selectableItemBackground">@drawable/icone_barratopo_selector</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@drawable/background_barratopo_superior</item>
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>

    <!-- Support library compatibility -->
    <item name="background">@drawable/background_barratopo_superior</item>
    <item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>

<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/application_color2</item>
</style>

<!-- ActionBar tabs text -->
<style name="MyActionBarTabText" parent="@style/Widget.AppCompat.ActionBar.TabText">
    <item name="android:textColor">@drawable/tab_text_selector</item>
</style>

<!-- ActionBar tabs styles -->
<style name="MyActionBarTabs" parent="@style/Widget.AppCompat.ActionBar.TabView">

    <!-- tab indicator -->
    <item name="android:background">@drawable/actionbar_tab_indicator</item>

    <!-- Support library compatibility -->
    <item name="background">@drawable/actionbar_tab_indicator</item>
</style>

我的 menu.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motobox="http://schemas.android.com/apk/res-auto" >

<!--
      <item
    android:id="@+id/option_availability"
    android:icon="@drawable/icone_barratopo_mymotobox"
    android:orderInCategory="100"
    motobox:showAsAction="always"/>
-->
<item
    android:id="@+id/option_refresh"
    android:icon="@drawable/icone_barratopo_back"
    android:orderInCategory="100"
    motobox:showAsAction="always"/>
<item
    android:id="@+id/status"
    android:orderInCategory="100"
    android:title="Indisponível"
    motobox:showAsAction="never"/>
<item
    android:id="@+id/logout"
    android:orderInCategory="100"
    android:title="Logout"
    motobox:showAsAction="never"/>

和我的 selector.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/application_color3" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>

<!-- Pressed -->
<item android:drawable="@color/application_color2" android:state_pressed="true"/>

<!-- Focused -->
<item android:drawable="@color/application_color2" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/>

4

2 回答 2

0

编辑该行:

<item name="background">@drawable/actionbar_tab_indicator</item>

<item name="android:background">@drawable/actionbar_tab_indicator</item>

:)

于 2014-01-30T20:15:23.203 回答
0

将您的文件从 重命名theme.xml

res/values/themes.xml

请记住,您可以将主题应用到整个应用程序

<application android:theme="@style/myCustomTheme">

或个人活动

<activity android:theme="@android:style/myCustomTheme">
于 2014-01-06T23:36:50.217 回答