title: How to have a searchview, on the toolbar like google?
body: <p>I do not look for any function in the searchview, in the toolbar, the click is treated so that it is directed to a search activity.</p>
  
  <p>Here is the toolbar I want:</p>
  
  <p><a href="https://i.stack.imgur.com/20h33.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/20h33.png" alt="enter image description here"></a></p>
  
  <p>This will always be expanded and clicking will be directed to another activity. Here are the codes:</p>
  
  <p>XML ToolBar Home:</p>
  
  <pre><code>        &lt;android.support.design.widget.AppBarLayout
              android:id="@+id/app_bar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
  
              &lt;android.support.v7.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  android:background="?attr/colorPrimary"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;
  
  &lt;!--                &lt;SearchView
                      android:id="@+id/search"
                      shapeColor="@color/white"
                      android:layout_width="match_parent"
                      android:layout_height="40dp"
                      android:background="@color/white"
                      android:onClick="@{(view) -&gt; viewModel.onSearchClicked(view)}"
                      android:queryHint="Pesquisar"
                      android:searchIcon="@drawable/ic_search_24dp"
                      android:voiceIcon="@drawable/ic_settings_voice_black_24px"
                      app:iconifiedByDefault="false"&gt;
  //TODO doesn't work
                  &lt;/SearchView&gt;--&gt;
  
              &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>Menu Home:</p>
  
  <pre><code>&lt;item
      android:id="@+id/item_search"
      android:orderInCategory="200"
      android:title="@string/search"
      android:icon="@drawable/ic_search_24dp"
      app:actionViewClass="android.support.v7.widget.SearchView"
      app:showAsAction="ifRoom|collapseActionView"
      android:iconifiedByDefault="false" /&gt;
  </code></pre>
  
  <p>HomeActivity:</p>
  
  <pre><code>    override val contentView = R.layout.view_home
  
      override fun onCreateOptionsMenu(menu: Menu): Boolean {
          menuInflater.inflate(R.menu.menu_home, menu)
  
          return super.onCreateOptionsMenu(menu)
      }
  
      override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
  /*        R.id.item_search -&gt; {
              startActivity(Intent(this, SearchActivity::class.java))
              true
          }*/
          R.id.item_zuk_code -&gt; {
              givenPermission(android.Manifest.permission.CAMERA, granted = {
                  startActivity(Intent(this@HomeActivity, ZukCodeReaderActivity::class.java))
              })
              true
          }
  //        R.id.item_contacts -&gt; {
  //            startActivity(Intent(this, ContactsSuggestionActivity::class.java))
  //            true
  //        }
          else -&gt; super.onOptionsItemSelected(item)
      }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>HomeActivity Menu:</p>
  
  <pre><code>override fun onCreateOptionsMenu(menu: Menu): Boolean {
      menuInflater.inflate(R.menu.menu_home, menu)
  
      val manager = getSystemService(Context.SEARCH_SERVICE) as SearchManager
      val search = menu.findItem(R.id.item_search).actionView as android.support.v7.widget.SearchView
      val si = manager.getSearchableInfo(componentName)
  
      var opt : Int = search.imeOptions
      search.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
      search.backgroundTintMode
      search.setSearchableInfo(si)
      search.setIconifiedByDefault(false)
  
      return super.onCreateOptionsMenu(menu)
  }
  </code></pre>
  
  <p>What I have:</p>
  
  <p><a href="https://i.stack.imgur.com/DajVw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DajVw.jpg" alt="enter image description here"></a></p>