title: How to modify SearchView close/clear button to always close the searchbox no matter whether it has content?
body: <pre><code>mSearchView.setOnCloseListener {
        // do something
  }
  </code></pre>
  <p>This method won't be called if the searchview contains some text. It is only called when the searchbox is empty.</p>
  <p><strong>UPDATE:</strong></p>
  <p><strong>menu xml:</strong></p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
      &lt;item
          android:id=&quot;@+id/action_scrolltotop&quot;
          android:icon=&quot;@drawable/ic_baseline_arrow_upward_24_white&quot;
          android:title=&quot;@string/action_scrolltotop&quot;
          app:showAsAction=&quot;ifRoom&quot; /&gt;
  
      &lt;item
          android:id=&quot;@+id/action_search&quot;
          android:icon=&quot;@android:drawable/ic_menu_search&quot;
          android:title=&quot;@string/action_search&quot;
          app:actionViewClass=&quot;android.widget.SearchView&quot;
          app:showAsAction=&quot;always&quot; /&gt;
  &lt;/menu&gt;
  </code></pre>
  <p>I use navigation component so I inflate the menu from a fragment.</p>
  <p><strong>onCreateOptionsMenu (from a fragment):</strong></p>
  <pre><code>override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
      super.onCreateOptionsMenu(menu, inflater)
  
      inflater.inflate(R.menu.menu_memories_tools, menu)
  
      val mSearch = menu.findItem(R.id.action_search)
      mSearchView = mSearch.actionView as SearchView
  
      mSearchView.setOnSearchClickListener {
          memoriesScrollView.smoothScrollTo(0, 0)
      }
  
      val closeBtn = mSearchView.findViewById&lt;ImageView&gt;(R.id.search_close_btn)
      closeBtn?.setOnClickListener {
          mSearchView.setQuery(&quot;&quot;, false)
          mSearchView.isIconified = true
      }
  
      mSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
          ...
      }
  }
  </code></pre>