Android actionLayout not showing using toolbar

I am trying to show a custom layout as an item in the options menu. And this is what I have done so far

<item android:id="@+id/action_profile" android:orderInCategory="100" android:title="Profile" android:actionLayout="@layout/layout_menu_profile" app:showAsAction="never" /> 

I tried

  app:actionLayout="@layout/layout_menu_profile" 

and also for this SO link, but still it only shows the title - Profile

I created a new project through Android Studio 1.5 with Blank Activity. with minSDK = 15 and targetSDK = 23

Below is the code in Blank Activity.

 @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_home, menu); MenuItem item = menu.findItem(R.id.action_profile); return true; } 

where am i wrong

+5
source share
2 answers

use app: actionLayout instead of android: actionLayout .

full code ...

 <item android:id="@+id/action_profile" android:orderInCategory="100" android:title="Profile" app:actionLayout="@layout/layout_menu_profile" app:showAsAction="always" /> 
+4
source

Try this code

 <item android:id="@+id/action_profile" android:orderInCategory="100" android:title="Profile" android:actionLayout="@layout/layout_menu_profile" app:showAsAction="always" /> 

Just set showAsAction elements to always

+2
source

Source: https://habr.com/ru/post/1243500/


All Articles