title: Why is the android.widget.SearchView not expanding on single click and instead moves the icon to left side?
body: <p>I am using <code>android.widget.SearchView</code> inside <code>MaterialToolbar</code> and have also set the correct attributes inside the menu reource file. But when I click the search icon, it doesn't expand. Instead, the search icon moves to the left side. On clicking it again, it expands but the search icon still appears inside the EditText.</p>
  
  <p><br></p>
  
  <p><strong>Layout file</strong></p>
  
  <pre><code>&lt;com.google.android.material.appbar.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;com.google.android.material.appbar.MaterialToolbar
          android:id="@+id/toolbar"
          style="@style/Widget.MaterialComponents.Toolbar.Primary"
          android:layout_width="match_parent"
          android:layout_height="?actionBarSize"
          app:title="@string/app_name" /&gt;
  
  &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  </code></pre>
  
  <p><strong>Menu file</strong></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"
          app:showAsAction="ifRoom|collapseActionView"
          app:actionViewClass="android.widget.SearchView" /&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p><br></p>
  
  <p>Before clicking</p>
  
  <p><a href="https://i.stack.imgur.com/n9lkK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n9lkK.png" alt="Before clicking"></a></p>
  
  <p>After clicking</p>
  
  <p><a href="https://i.stack.imgur.com/M0nnn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M0nnn.jpg" alt="After clicking"></a></p>
  
  <p><a href="https://imgur.com/a/FhSV3dQ" rel="nofollow noreferrer">SearchView hint </a></p>