Reputation: 137
about android Toolbar
, how to hide default setting menu in toolbar
in the this activity i hava set a single icon menu,like this –
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:title=""
android:id="@+id/menu_add"
android:icon="@drawable/actionbar_add_icon"
android:showAsAction="ifRoom">
</item>
</menu>
it is menu/main_home.xml
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);
return super.onCreateOptionsMenu(menu);
}
but it show a three dots menu. i want know why
and how to show sub menu icon image ,it is normal in the Actionbar
, but hide in the Toolbar
Upvotes: 1
Views: 2315
Reputation: 137
this question is solved use app:showAsAction ="ifRoom" not android:showAsAction ="ifRoom"
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:title=""
android:id="@+id/menu_button"
app:actionLayout="@layout/menu_single_button"
app:showAsAction = "always"
/></menu>
Upvotes: 2
Reputation: 1877
If you want to empty the contents of the menu, go to the res/menu folder and delete the item tags from the menu_main.xml file. You will also need to delete references to the items in onOptionsItemSelected(MenuItem item)
. The menu dots will disappear if there are no items.
If you want to completely remove the three dots menu, then go to the onCreateOptions(...)
method in your code and delete it, or simply remove the getMenuInflater().inflate(...);
portion of it. You can safely remove the onOptionsItemSelected(MenuItem item)
method as well because it will have no purpose.
The simplest way to make the menu disappear is to have the onCreateOptions(...)
method return false.
Upvotes: 6