5

I have a centered view in Toolbar. When I add MenuItems, the content gets pushed so it's is not centered. I know ActionMenuView is an option but SearchView doesn't expand this time (another question). I've tried contentInset attributes but no luck.

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:gravity="center"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FF0000">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:padding="4dp"
            app:srcCompat="@drawable/ic_ugurlogo_white" />

    </FrameLayout>

</android.support.v7.widget.Toolbar>

Here is the result. Red view is the FrameLayout. I want the FrameLayout to match Toolbar width.

Toolbar

How am I gonna achieve this?

osrl
  • 8,168
  • 8
  • 36
  • 57

0 Answers0