I tried different combinations in xml file:
You can use following code for establishing your purpose. No need to make it programmatic. You can trick in menu.xml file.
menu.xml
In above code, we've used menu
inside of item
. In inside menu, we've defined our overflow menu which we want with icon. Just remember to use app:showAsAction="always"
in outside item
tag.