Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override context menu colors in Android

Let's see,

i know how to change the style of a ListView (the orange color when an item is selected):

android:listSelector="@drawable/xxx" and a drawable with a bitmap or a @color

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/image" />
    <item android:drawable="@android:color/transparent" />  
</selector> 

The thing is, in order to have a coherent design, i have to do the same thing for a context menu but i just can't see where to change it. There is no listSelector, nothing to change.

like image 539
ferostar Avatar asked Jan 05 '11 13:01

ferostar


1 Answers

Here is how you do it. Go to resources > styles.xml and override the theme's itemBackgroud attribute value as follows:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="android:itemBackground">"YOUR_COLOUR_HERE"</item>
</style>

If this doesn't work, check in AndroidManifet.xml that you are really using the same theme at App level:

<application
    ...
    android:theme="@style/AppTheme">

    ...

 </application>
like image 159
J. Doe Avatar answered Oct 14 '22 07:10

J. Doe