title: How to align icon to the right and text to the left in the App Bar?
body: <p>I am trying to display two icons to the right of my App Bar, I figured the way to place the very right icon to the right of the app bar, sadly i can only place the other icon next to the text (which means it it either placed to the very right with the text to the very right or to the very left with the title to the very left.</p>
  
  <p>I want the page title to the left (as it is by default) and the <code>search</code>-icon as well as the <code>settings</code>-button to the right next to each other.</p>
  
  <p>I also tried setting the <code>width</code> of my <code>LinearLayout</code> to <code>match_parent</code> instead of <code>wrap content</code>, yet that causes the <code>ImageButton</code> to be out of the bounds of the window (and not getting displayed because of that). Setting the <code>margin</code> causes the same effect. I could also not move the <code>ImageButton</code> into the <code>LinearLayout</code>, since that causes the same problem as changing the <code>width</code> of the <code>LinearLayout</code>.</p>
  
  <p>What it looks like (actually):</p>
  
  <p><a href="https://i.stack.imgur.com/fcJls.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fcJls.png" alt="enter image description here"></a></p>
  
  <p>This is almost fine, except for the text that I wish to be oriented to the start instead of the end. I'd like to avoid setting specific <code>dp</code> as width, since this will cause problems on different devices right?</p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>&lt;androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
          android:id="@+id/appbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:orientation="horizontal"
              android:layout_gravity="right"
              android:layout_marginEnd="0dp"&gt;
  
              &lt;androidx.appcompat.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  app:popupTheme="@style/AppTheme.PopupOverlay"
                  &gt;
  
                  &lt;SearchView
                      android:id="@+id/toolbar_search"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:maxWidth="1000000dp" /&gt;
  
              &lt;/androidx.appcompat.widget.Toolbar&gt;
  
              &lt;androidx.appcompat.widget.AppCompatImageButton
                  android:id="@+id/toolbar_settings_button"
                  android:layout_width="40dp"
                  android:layout_height="match_parent"
                  android:src="@drawable/ic_settings_icon_foreground"
                  android:background="@color/colorPrimary"
                  /&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>