Suppose I do not want to refer to an external file using app:actionLayout . How instead of app:actionLayout insert the markup code directly into <item> ?

 <item android:id="@+id/item1" android:title="@string/item1" app:actionLayout="@layout/layout1" // сюда код layout с произвольным содержимым app:showAsAction="always" /> 
  • It is impossible, I think. Moreover, I do not see any reason not to use the "separate file". - Vladyslav Matviienko
  • Just if the application is large, then there will be a lot of files. For my little programming experience with android, I found that almost every new menu-type gadget provides 2-3 new files. - Side Gleb
  • 2
    Call them just right so that you can easily find them - Vladyslav Matviienko

1 answer 1

You can insert elements into the toolbar and process them yourself

 <android.support.v7.widget.Toolbar> <CustomLayout/> </android.support.v7.widget.Toolbar>