0

So I want the Background Colour button to have an icon next to it on the first layer of this options menu, but it doesn't appear. (See image 1)

Top layer of options menu

I have exactly the same code for the subitems of this Background Colour option, but this shows the icon?

Red option has an icon despite having the same code as its parent

This is what my XML looks like, it has the same code for the icon implementation:

enter image description here

What can I do to get the bucket icon to appear next to Background Colour?

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Terminal Guy
  • 178
  • 1
  • 11
  • 2
    Does this answer your question? [Android menu item with both icon and text together when showAsAction is never](https://stackoverflow.com/questions/33777318/android-menu-item-with-both-icon-and-text-together-when-showasaction-is-never) – Ahmed Shahid Jul 20 '20 at 17:57
  • Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. If you post images of code or error messages, make sure you also copy and paste or type the actual code/message into the post directly. Please see [Why may I not upload images of code on SO when asking a question?](//meta.stackoverflow.com/a/285557/208273)—the same reasoning applies to error messages as well. Posts in which required text content is only present in images are likely to be closed as lacking enough details. – Ryan M Jul 22 '20 at 05:08

1 Answers1

0

Your code seems fine, so I tried something similar to my app and found out that when I removed the icons from the rest menu items and leave the icon declaration only to 1 icon in xml then this 1 icon wouldn't show either sometimes.
Try it yourself.
Set icons to the rest of the items too User Setup and Settings and see what happens.

forpas
  • 160,666
  • 10
  • 38
  • 76
  • I put it on every menu option and it doesn't appear in any of "background colour", "user setup" or "settings", but does for all 3 colours. Also tried it in another app and I'm still getting the same problem. – Terminal Guy Oct 24 '18 at 20:17
  • Can you see the icon in xml at the left of `android:icon="@drawable/...."`? – forpas Oct 24 '18 at 20:22
  • They aren't there on this app, however they are on another app I made (but even when the icon is to the left of the code it still does not display it in the option menu). – Terminal Guy Oct 24 '18 at 20:25
  • So copy the icon from the other app and paste it in drawable folder in this app and see what happens. – forpas Oct 24 '18 at 20:27
  • I did it and the icon from the other app appears to the left of the code, however still the same issue - nothing on the top layer but appearing in the colours layer. – Terminal Guy Oct 24 '18 at 20:31
  • Ok, clean the project and if needed invalidate and restart – forpas Oct 24 '18 at 20:35