You can remove the back button after clicking a search (expanded)

I have one action with the action bar. The action bar contains a search. I do not want this return button that appears when you click on the search search. Can I delete it or hide it? This back button is not displayed until I press the search button. By the way, the following line of code does not help.

getSupportActionBar().setDisplayHomeAsUpEnabled(false);

enter image description here

Menu resource

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

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

</menu>
+4
source share
2 answers

I have a similar problem. To just remove the arrow, I changed app:showAsAction="always|collapseActionView"to app:showAsAction="always". However, now I have a space instead of an arrow, which is a problem that I haven't solved yet.

+5
source

, ,

: collapseIcon

.

<android.support.v7.widget.Toolbar
         android:id="@+id/toolbar"
         android:layout_width="match_parent"
         android:layout_height="@dimen/toolbarHeight"
         app:collapseIcon="@drawable/collapseBackIcon" />
+3

All Articles