title: Expandable Search in Android
body: <p>Duplicate of this closed question: <a href="https://stackoverflow.com/questions/29149268/how-to-implement-search-bar-like-gmail-app-in-android">How to implement Search Bar like gmail app in android?</a></p>
  
  <p>I've been trying to implement expandable search that is displayed and implemented in the current YouTube and Photos Android application among others but I have been unable to figure it out. I only get something like this picture which is far from it. Also, the suggestions adapter background seems to be black instead of white for some reason. Can someone provide some code or hints on how to implement expandable search? I am NOT looking for persistent search.
  <a href="https://i.stack.imgur.com/v0FuU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v0FuU.png" alt="current status"></a></p>
  
  <p>My code is here:</p>
  
  <pre><code> &lt;activity
          android:name=".activity.MainActivity"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
          &lt;!-- this intent has to be in here or else search won't work --&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.SEARCH"/&gt;
          &lt;/intent-filter&gt;
          &lt;meta-data
              android:name="android.app.searchable"
              android:resource="@xml/searchable" /&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>MainActivity optionsMenu seems ok:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      MenuItem searchItem = menu.findItem(R.id.action_search);
      SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
      SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
      // Configure the search info and add any event listeners
      searchView.setIconifiedByDefault(true);
      searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  
      return super.onCreateOptionsMenu(menu);
  }
  </code></pre>
  
  <p>Options menu seems okay as well:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto" &gt;
  &lt;item android:id="@+id/action_search"
      android:title="@string/action_search"
      android:icon="@drawable/ic_search_white"
      app:showAsAction="ifRoom|collapseActionView"
      app:actionViewClass="android.support.v7.widget.SearchView" /&gt;
  &lt;/menu&gt;
  </code></pre>