I have a toolbar and I want to add an ImageView
to its layout in xml. I want it to align right, instead of the default align left.
According to the documentation:
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.
But I can't set the gravity on anything.
My Layout
<android.support.v7.widget.Toolbar
style="@style/ToolbarStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize">
<ImageView
android:id="@+id/bluetoothState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_bluetooth_status_white"
android:contentDescription="@string/content_description_bluetooth_status"
android:padding="8dp"/>
</android.support.v7.widget.Toolbar>