title: Action Bar Icon Positioning Android
body: <p>I have created a custom action bar for my Android App, with the help of the Toolbar class. It still shows the menu button to the left of the action bar, which converts to an arrow when click. I need to keep this icon as I have a side menu.</p>
  
  <p>The problem I have is that the other icons I have, which are defined in my XML file are not centering correctly.</p>
  
  <p>Below is an example of my aim, but it isn't a perfect example as there are 3 icons in the middle, not 2.</p>
  
  <p><a href="https://i.stack.imgur.com/rxSEE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rxSEE.jpg" alt="Example of issue"></a></p>
  
  <p>I am aware that the issue can be fixed quickly by just removing the android menu icon to the left, but I would like to keep it if possible. I am also aware that my icons are centering, but are centering based on the area to the right of the menu icon.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize"
      android:elevation="4dp"&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal" android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_gravity="center"
          android:layout_marginTop="0dp"
          android:gravity="center"
          android:layout_alignParentTop="true"
          android:id="@+id/top_bar"
          android:weightSum="3"&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:layout_gravity="center"
          android:gravity="center"
          android:layout_weight="1"
          &gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_gravity="center"
              android:gravity="center"
              android:layout_weight="1"
              &gt;
  
  
              &lt;ImageButton
                  android:id="@+id/icon1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:contentDescription="Icon1"
                  android:src="@drawable/icon1"
                  android:background="@null"
                  android:tint="#ffffffff"
                  android:layout_marginRight="10dp"
                  android:alpha="0.2"/&gt;
  
  
              &lt;ImageButton
                  android:id="@+id/icon2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:contentDescription="@string/icon2"
                  android:src="@drawable/icon2"
                  android:background="@null"
                  android:tint="#ffffff"
                  android:maxHeight="25dp"
                  /&gt;
  
              &lt;ImageButton
                  android:id="@+id/icon3"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:contentDescription="icon3"
                  android:src="@drawable/icon3"
                  android:background="@null"
                  android:tint="#ffffffff"
                  android:layout_marginLeft="10dp"
                  android:alpha="0.2" /&gt;
          &lt;/LinearLayout&gt;
  
  
  
          &lt;ImageButton
              android:id="@+id/icon4"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:contentDescription="icon4"
              android:src="@drawable/icon4'"
              android:background="@null"
              android:tint="#FFFFFF"
              android:layout_marginTop="0dp"
              android:layout_weight="1"
              android:layout_gravity="right|center_vertical"
              /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>Am I meant to be setting the position of these icons programatically and fixed positioned? Or am I totally missing something here?</p>
  
  <p>Can someone point me in the right direction please. Thank you!</p>