4

I have applied the following code in values-v11 folder

styles.xml

 <style name="actionBarTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
 </style>

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

But it not changing the overflow icon, all the other items in this theme is working fine but not this one, am i missing anything ?

Raghunandan
  • 132,755
  • 26
  • 225
  • 256
Kanika
  • 10,648
  • 18
  • 61
  • 81

3 Answers3

10
 i want to apply these styles above 4.0 version 

But you have the styles in values-v11

Also note

parent="android:Theme.Holo.Light" // in your code

to

parent="@android:style/Theme.Holo" // mine

It should be in values-v14

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="MyTheme" parent="@android:style/Theme.Holo">
        <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
    </style>
    <style name="MyActionButtonOverflow" parent="@android:style/Widget.Holo.Light.ActionButton.Overflow">
       <item name="android:src">@drawable/ic_launcher</item>    
    </style>
</resources>
Snap

Forget how the ui look's this is for testing. But you see the launcher icon as the overflow menu icon.

enter image description here

Edit:

This is my test sample

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
             <item name="android:actionBarStyle">@style/MyActionBar</item>
              <item name="android:actionBarDivider">@color/red</item>
              <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
    </style>

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
         <item name="android:background">#FF9D21</item>

         <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
    </style> 
    <style name="MyActionBarTitleText"
           parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
        <item name="android:textColor">@color/red</item>
        <item name="android:textStyle">bold</item>
    </style>
      <style name="MyActionButtonOverflow" parent="@android:style/Widget.Holo.Light.ActionButton.Overflow">
    <item name="android:src">@drawable/launcher</item>    
    </style>
    <style name="ActionButton" parent="@android:style/Widget.Holo.Light.ActionButton">
</style>
</resources>

Colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#FF0000</color>
</resources>

Snap

enter image description here

Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • ok, Got the point..Thanks alot..Also I want to add a divider at the end of action bar. I am using but again it is not working – Kanika Jan 23 '14 at 08:57
  • @Kanika that's a different question. to the question asked i have answered – Raghunandan Jan 23 '14 at 09:26
  • I dont know why its not working on my side ? I have applied everything as you said – Kanika Jan 24 '14 at 12:38
  • @Kanika i can only post what is working and what can work. I don't know how you are doing. – Raghunandan Jan 24 '14 at 12:43
  • @Raghunandan Need to ask for what we need to place in values and values-v11 style files... Also I am getting IllegalException and getting suggestion on for to use Theme.Appcompat. – AndroidHacker Jan 31 '14 at 11:43
  • 1
    @AndroidHacker that is because you need to use AppCompat library and you should use AppCompat Theme. For values-11 see the docs its all there – Raghunandan Jan 31 '14 at 12:34
1

i think you should do the following :

<style name="MyCustomTheme" parent="style/Theme.Holo">
    <item name="android:actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
</style>

<style name="MyCustomTheme.OverFlow">
    <item name="android:src">@drawable/my_overflow_image</item>
</style>
0

You can set it programmatically in Java like this:

toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.your_icon, null));