Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you remove back button after search view has been clicked (expanded)

I have one activity with action bar. Action bar contains search view. I don't want that back button which appears when search view is clicked. Is it possible to remove it or hide it? That back button is not visible until I click the search view. By the way the following line of code doesn't 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>
like image 785
Egis Avatar asked May 18 '15 13:05

Egis


People also ask

How do I remove the back button from my Toolbar?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

Do all Android devices have a back button?

All Android devices provide a Back button for this type of navigation, so you should not add a Back button to your app's UI. Depending on the user's Android device, this button might be a physical button or a software button.


1 Answers

I have been dealing with a similar issue. To simply remove the arrow, I changed app:showAsAction="always|collapseActionView" to app:showAsAction="always". However, now I have a blank space instead of the arrow, which is an issue I have yet to resolve.

like image 135
nivekgnay Avatar answered Sep 17 '22 16:09

nivekgnay