Android Studio layout design view doesn't show menu bar items?

592 Views Asked by At

i've defined a simple menu in res/menu/simple_menu.xml, with a single item called TITLE2. i then iflate this menu in my MainActivity, and all is good (See device screenshot on right, where my TITLE2 is visible in the action bar top right. however, in the layout preview (activity_main.xml, Design view, left image in below) the menu item is not visible! is this intentional? is there a way to get my menu items to show up in preview mode? thanks,

preview view (left) vs view on actual device (right)

2

There are 2 best solutions below

0
Tanish On
<item
    android:title="TITLE2"
    app:actionProviderClass="com.example.chimee.MyActionProvider"
    app:showAsAction="collapseActionView"/>

play with showAsAction for a while collapseActionView will add an item menu to a vertical list menu Something like this:

enter image description here

0
Kakyire On

is there a way to get my menu items to show up in preview mode?

No, because the menu items show up in the action bar after you inflate it in your Kotlin/Java code.