title: How to extend the ActionBar
body: <p>When I try to add a view immediately under the ActionBar, it only seems to work if I add an ImageView, as shown below.</p>
  
  <p>The same doesn't work with LinearLayout, or RelativeLayout, and instead removes all of the ActionBar's initial content and replaces it with the Linear/ Relative Layout content.</p>
  
  <p>Why can't I successfully add LinearLayout, or RelativeLayout, or what might I be getting wrong. I just started working with Android.</p>
  
  <p>I'm aiming for something like this:
  <img src="https://i.stack.imgur.com/TXh43.png" alt="enter image description here"></p>
  
  <p>-- THE CODE</p>
  
  <p>Extend our ActionBar by adding an ImageView</p>
  
  <pre><code>    ActionBar actionBar = getActionBar();
      actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  
      ImageView imageView = new ImageView(actionBar.getThemedContext());
      imageView.setScaleType(ImageView.ScaleType.CENTER);
      imageView.setImageResource(R.drawable.center16);
      ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(
              ActionBar.LayoutParams.WRAP_CONTENT,
              ActionBar.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM
              | Gravity.CENTER_VERTICAL);
      layoutParams.rightMargin = 40;
      imageView.setLayoutParams(layoutParams);
      actionBar.setCustomView(imageView);
  </code></pre>
  
  <p>Using a Linear or Relative layout</p>
  
  <pre><code>    LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View linearorrelative = inflator.inflate(R.layout.actionbarextend, null);
  
      ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(
              ActionBar.LayoutParams.WRAP_CONTENT,
              ActionBar.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM
              | Gravity.CENTER_VERTICAL);
      layoutParams.rightMargin = 40;
      linearorrelative.setLayoutParams(layoutParams);
      actionBar.setCustomView(linearorrelative);
  </code></pre>