After switching to the toolbar, there is a problem with the menu icons. Although I set android: showAsAction = "always" for the menu item, it does not show the icon, I can only find it by clicking on the popup window icon.
This is myActivity
public class myActivity extends AppCompatActivity{ ......... public void onCreate(....){ ............. Toolbar toolbar = (Toolbar) findViewById(....); setSupportActionBar(toolbar); } ............ public boolean onCreateOptionsMenu(Menu menu{ getMenuInflater().inflate(R.menu.menu, menu); return super.onCreateOptionsMenu(menu); } ............. }
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/settings" android:icon="@drawable/settings" android:title="settings" android:showAsAction="always" /> <item android:id="@+id/help" android:icon="@drawable/help" android:title="help" android:showAsAction="never" /> </menu>
Both settings and help icons are only available in the pop-up menu. So, how to show the settings icon in the toolbar?
source share