title: ActionBar with custom layout with custom menu item
body: <p>I want to make custom action bar by put <code>ImageView</code> in the middle and have another icon with some info on the right side of actionbar like this:</p>
  
  <p><a href="https://i.stack.imgur.com/bZUvJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bZUvJ.png" alt=""></a></p>
  
  <p>I can make imageview in the middle already but problem is</p>
  
  <ul>
  <li>when i inflate layout in <code>onCreateOptionMenu()</code> and set <code>showAsAction="always"</code> the view on the right take all space of action bar like this </li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/6llu5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6llu5.png" alt=""></a></p>
  
  <p>but if i set it to <code>"never"</code> the middle image will show but menu item will gone</p>
  
  <p>here is my code :</p>
  
  <pre><code>private void setActionBar(){
          actionBar = getActionBar();
          actionBar.setHomeButtonEnabled(true);
          actionBar.setDisplayShowHomeEnabled(true);
          actionBar.setDisplayUseLogoEnabled(true);
          actionBar.setDisplayShowCustomEnabled(true);
          actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
  
          LayoutInflater linflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
          View view = linflater.inflate(R.layout.actionbar_layout, null);
          ActionBar.LayoutParams lp = new ActionBar.LayoutParams(
                  ActionBar.LayoutParams.WRAP_CONTENT,
                  ActionBar.LayoutParams.WRAP_CONTENT);
          lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
          view.setLayoutParams(lp);
          actionBar.setCustomView(view);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater menuInflater = getMenuInflater();
          menuInflater.inflate(R.menu.actionbar_right_icon, menu);
          MenuItem menuItem = menu.findItem(R.id.user_info);
  
          View rightIcon = menuItem.getActionView();
          RelativeLayout rightIconLayout = (RelativeLayout) rightIcon.findViewById(R.id.actionbar_right_icon);
          TextView user = (TextView) rightIconLayout.findViewById(R.id.actionbar_user);
          TextView id = (TextView) rightIconLayout.findViewById(R.id.actionbar_id);
  
          user.setText("User:test");
          id.setText("ID:xxxxx");
  
          return true;
      }
  </code></pre>
  
  <p>menu/actionbar_right_icon</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" 
      &gt;
      &lt;item 
          android:id="@+id/user_info"
          android:actionLayout="@layout/actionbar_right_icon_layout"
          android:icon="@drawable/user_icon"
          android:showAsAction="always"
  
          /&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>how can i fix this?</p>
  
  <p>thank you in advance</p>