1

I want to hide all icons in action bar when user touches the search icon. But one icon is not hiding.

My xml:

<?xml version="1.0" encoding="utf-8"?> 
<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:icon="@drawable/ic_search_white_36dp"
          android:title="Ara"
          app:showAsAction="always"
          android:iconifiedByDefault="true"
          app:actionViewClass="android.widget.SearchView"/>


    <item android:id="@+id/action_shuffle"
          android:icon="@drawable/ic_autorenew_white_24dp"
          android:title="Karıştır"
          app:showAsAction="always" />

    <item android:id="@+id/action_premium"
        android:icon="@drawable/ic_star_white_24dp"
        android:title="Premium"
        app:showAsAction="always" />

    <item android:id="@+id/action_favorites"
          android:icon="@drawable/ic_people_white_24dp"
          android:title="Takip Listesi"
          app:showAsAction="always" />

    <item android:id="@+id/action_settings"
          android:icon="@drawable/ic_settings_white_24dp"
          android:title="Settings"
          app:showAsAction="always" />

        <item android:id="@+id/action_fullpicture"
          android:icon="@drawable/ic_action_picture"
          app:showAsAction="always"
          android:visible="false" />    
</menu>

Before:

enter image description here

After:

enter image description here

How can I hide action_shuffle too? Other icons automaticly hiding I didn't do anything special.

Tolgay Toklar
  • 4,151
  • 8
  • 43
  • 73

1 Answers1

0

You should change the app:showAsAction = "always" to app:showAsAction = "ifRoom".

Other way could be this answer, take a look.

Community
  • 1
  • 1
Skizo-ozᴉʞS ツ
  • 19,464
  • 18
  • 81
  • 148