6
votes

I want to to customize my app and i've applied a theme but the options menu doesn't seem to apply my theme.

I want my text color to be white, my background to be black and the highlighted/selected menu item to be yellow. Here is my theme.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>

My 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"/>

and my 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"/>

2

2 Answers

0
votes

Rename your file from theme.xml to

res/values/themes.xml

And remember you can apply your theme to your entire app

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

or individual activities

<activity android:theme="@android:style/myCustomTheme">
0
votes

Edit the line:

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

to

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

:)