title: How do I Change the Alignment of Toolbar Child Views
body: <p>I have a toolbar and I want to add an <code>ImageView</code> to its layout in xml. I want it to align right, instead of the default align left.</p>
  <p>According to the <a href="https://developer.android.com/reference/android/support/v7/widget/Toolbar.html" rel="noreferrer">documentation</a>:</p>
  <blockquote>
  <p>The application may add arbitrary child views to the Toolbar. They will appear at this position within the layout. If a child view's Toolbar.LayoutParams indicates a Gravity value of CENTER_HORIZONTAL the view will attempt to center within the available space remaining in the Toolbar after all other elements have been measured.</p>
  </blockquote>
  <p>But I can't set the gravity on anything.</p>
  <h3>My Layout</h3>
  <pre class="lang-xml prettyprint-override"><code>&lt;android.support.v7.widget.Toolbar
      style=&quot;@style/ToolbarStyle&quot;
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:background=&quot;?attr/colorPrimary&quot;
      android:minHeight=&quot;?attr/actionBarSize&quot;&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/bluetoothState&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:src=&quot;@drawable/ic_bluetooth_status_white&quot;
          android:contentDescription=&quot;@string/content_description_bluetooth_status&quot;
          android:padding=&quot;8dp&quot;/&gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  <p><img src="https://i.stack.imgur.com/jFYCJ.png" alt="Default Alignment" /></p>