In KitKat, I have a styled options menu in a supported library toolbar defined as following
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="?attr/colorPrimary"
app:theme="@style/ToolbarText"
app:popupTheme="@style/optionMenu"
/>
where the optionMenu style is
<style name="optionMenu">
<item name="android:textColor">@color/menu_text</item>
<item name="android:background">@color/menu_background</item>
</style>
It works as expected, but when i press a MenuItems, it doesn't take the "default grey" color in all available space, but only on the edges around the menu element whose background remains colored as defined in the style. My goal is not to change the style onpressed event, i wish only that the background behind the text looks like the whole rectangular button when pressed
Where am I wrong?
Finally after looking around in the default library for more than a day, I got it working under my application with the following tweaks:
Layout File
Styles
Under the
@dimen/toolbar_elevation
I have just mentioned "4dp" but that is not of concerns here. With the<item name="android:colorBackground">
I was able to set the normal background and with the<item name="listChoiceBackgroundIndicator">
I was able to set the on-pressed background of the menu items.I hope this is of help