So you created an overflow menu that contains another sub-menu in Android’s ActionBar. Everything works well after you styled the background color of Widget.AppCompat.PopupMenu.

Once you tried a long click on the overflow MenuItem and proceed to selected a sub MenuItem, you notice the selected background color of the item is not transparent.

The cause for this is because you used android:background. The correct attribute to use is android:colorBackground.

That should fix it.

See sample XML code:

And in your theme style, add this:

It was a pain to have to look for a way to change the color of the Spinner widget’s selected item because the color displayed in the screen is dark.

Using Theme.AppCompat.Light.DarkActionBar, the problem is that the Spinner blends in with the ActionBar’s dark background (black in my case).

I did not want to have to create another layout just for the Spinner widget alone and use it as the actionLayout attribute value of the MenuItem.

So the only solution left is to do it programmatically.

Here is the code snippet:

It seems that whenever I set an ActionView of an ActionBar MenuItem, its alignment moves to the left. Worse, there was a case wherein the 3 dotted icon also moved to the right.

When I decided to use an animation in the refresh icon, only this one moved. The 3 dotted icon stayed put. Good, right?

At least I only had one problem left to solve. So my ActionView XML Layout looks like this:

This should work. Adding a padding to both the left and right should make the ActionView drawable stay put.

Also worth noting is that even if you use the Toolbar class, the same thing happens when you set the animating ActionView. This layout with the correct padding values should fix that.

Related Posts Plugin for WordPress, Blogger...