Why did my HomeAsUp icon disappear after I used the action actionview in the action bar

The attribute in my activity is as follows:

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);

And the menu layout of my menu is below:

 <item android:id="@+id/action_search"
          android:icon="@drawable/ic_action_search"
          com.xxx:showAsAction="ifRoom|collapseActionView"
          com.xxx:actionViewClass="android.support.v7.widget.SearchView"
          android:title="weibo"/>

But if I press the search button and return, the homeasup icon that I want to use with the manure box will disappear. I do not know why.

Everything will be fine if I remove actionBar.setDisplayShowHomeEnabled(false). .

+4
source share
1 answer

I have the same problem. My workaround was to use a 1 pixel transparent icon as the house icon, so that I could remove the setDisplayShowHomeEnabled (false) method, but still DO NOT have the icon as it is transparent.

-1

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


All Articles