title: Center position of logo in Action Bar Android
body: <p>I want to display the logo at the centre of the Action Bar. Here's my custom layout code:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/ActionBarWrapper"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:orientation="horizontal"&gt;
  
      &lt;ImageView
          android:id="@+id/icon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/logo"
          android:layout_centerInParent="true"
          android:padding="8dp"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And in the <code>onCreate()</code> I'm using it as:</p>
  
  <pre><code>getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.custom_logo);
  getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#2A2A2A")));
  </code></pre>
  
  <p>The issue is it displays fine in normal Fragments and Activity but shifts a little to the right when used with Navigation Drawer. Here are the images:</p>
  
  <ol>
  <li>Wrong One: </li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/KZD7t.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KZD7t.png" alt="Wrong Display"></a></p>
  
  <ol start="2">
  <li>Right One:</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/wpYb3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wpYb3.png" alt="Right Display"></a></p>
  
  <p>What am I doing wrong? Thanks.</p>