I want my search view widget to fill the entire toolbar so in menu.xml I did this:
...
app:showAsAction="always"
This seem to hide all other items in the toolbar when search view expands, but not the drawer toggle button:

Is there anyway I can make the search view widget fill the entire toolbar and hide the toggle button too? Thanks
You can achieve this by hiding the hamburger button. Set your toolbar navigation icon to null.
toolbar.setNavigationIcon(null);
EDIT
To remove the navigation icon, add the following line in your onCreate method.
getActionBar().setDisplayHomeAsUpEnabled(false);
or
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
To make the SearchView fill the action bar, set the width of the SearchView to max in the onCreateOptionsMenu method.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_search, menu);
SearchView searchView =
(SearchView)menu.findItem(R.id.menu_search).getActionView();
searchView.setMaxWidth(Integer.MAX_VALUE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With