title: How to keep expanded SearchView on the right side of ActionBar (while using custom icon)?
body: <p>My question is closely related to <a href="https://stackoverflow.com/questions/18255315/searchview-wrong-alignment">SearchView wrong alignment</a> and <a href="https://stackoverflow.com/questions/19316113/searchview-positions-when-expanded-in-actionbar">SearchView positions when expanded in ActionBar</a> but the answers posted there do not work.</p>
  
  <p>So, I'm using a <a href="http://developer.android.com/guide/topics/search/search-dialog.html" rel="nofollow noreferrer">SearchView</a> in the <a href="http://developer.android.com/guide/topics/ui/actionbar.html" rel="nofollow noreferrer">Action Bar</a>:</p>
  
  <pre><code>&lt;item android:id="@+id/action_search"
      android:icon="@drawable/navi_search"
      android:title="@string/action_search"
      android:showAsAction="ifRoom|collapseActionView"
      android:actionViewClass="android.widget.SearchView"
     /&gt;
  </code></pre>
  
  <p>It looks like this by default (top-right corner, next to overflow menu):</p>
  
  <p><img src="https://i.stack.imgur.com/X3z1K.png" alt="enter image description here"></p>
  
  <p>Problem is, when expanded, <strong>I'd like the SearchView to stay on the right</strong>, but instead, it moves to the left edge, next to home button (app icon).</p>
  
  <p>I tried changing <code>showAsAction</code> to either of these (<a href="https://stackoverflow.com/a/18271539/56285">as suggested here</a>):</p>
  
  <pre><code>android:showAsAction="ifRoom"
  android:showAsAction="always"
  </code></pre>
  
  <p>...And that does fix the alignment when expanded, but <strong>the custom icon is lost</strong> when in collapsed state:</p>
  
  <p><img src="https://i.stack.imgur.com/eO5yj.png" alt="enter image description here"></p>
  
  <p>Also, stuff like <code>android:layout_alignParentRight="true"</code> and <code>android:layout_centerInParent="true"</code> on the menu <code>&lt;item&gt;</code> have no effect.</p>
  
  <p>Any ideas? </p>
  
  <p>I'm targetting Android 4.0 and above:</p>
  
  <pre><code>&lt;uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /&gt;
  </code></pre>