title: Action bar: Best practice for older Android versions
body: <p><strong>I would like to have a menu bar at the top of my application - just like Facebook, Google+ or Twitter have:</strong></p>
  
  <p>Here's a screenshot from the Twitter app which shows this bar: It is shown in every activity and features the company logo on the left (clickable) and 1-3 menu items (clickable images) on the right.</p>
  
  <p><img src="https://i.stack.imgur.com/eBFVr.png" alt="enter image description here"></p>
  
  <p>It can also be seen in the GDCatalog app:</p>
  
  <p><img src="https://i.stack.imgur.com/HpFvf.jpg" alt="enter image description here"></p>
  
  <p>So there are a few requirements for that action bar:</p>
  
  <ul>
  <li>It has to work on older Android platforms, too, such as API level 8.</li>
  <li>It has to be available in every activity without repeating the code time and again.</li>
  <li>It has to adapt to the screen size so that it takes the full width.</li>
  </ul>
  
  <p><strong>What's the best practice to implement such an action bar?</strong></p>
  
  <p>GreenDroid does it like that (using merges):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;!--
  /*
  ** Copyright (C) 2010 Cyril Mottier (http://www.cyrilmottier.com)
  **
  ** Licensed under the Apache License, Version 2.0 (the "License");
  ** you may not use this file except in compliance with the License.
  ** You may obtain a copy of the License at
  **
  **     http://www.apache.org/licenses/LICENSE-2.0
  **
  ** Unless required by applicable law or agreed to in writing, software
  ** distributed under the License is distributed on an "AS IS" BASIS,
  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ** See the License for the specific language governing permissions and
  ** limitations under the License.
  */
  --&gt;
  
  &lt;merge
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;ImageButton
          xmlns:android="http://schemas.android.com/apk/res/android"
          style="?attr/gdActionBarItemStyle"
          android:id="@+id/gd_action_bar_item"
          android:layout_height="fill_parent"
          android:scaleType="center" /&gt;
  
      &lt;ImageView
          android:layout_width="?attr/gdActionBarDividerWidth"
          android:layout_height="fill_parent"
          android:background="?attr/gdActionBarDividerDrawable" /&gt;
  
      &lt;TextView
          style="?attr/gdActionBarTitleStyle"
          android:id="@+id/gd_action_bar_title"
          android:layout_width="0dp"
          android:layout_height="fill_parent"
          android:layout_weight="1.0"
          android:gravity="left|center_vertical"
          android:singleLine="true"
          android:textColor="?attr/gdActionBarTitleColor"
          android:textSize="16sp"
          android:textStyle="bold"
          android:paddingRight="10dp"
          android:paddingLeft="10dp" /&gt;
  
  &lt;/merge&gt;
  </code></pre>
  
  <p>Is this a good solution? Will it work on older platforms as well? What coding parts are still missing here?</p>
  
  <p>I know that we can find several questions about these action bars here yet. But nevertheless, I couldn't find out what is the best and easiest way to implement the menu bar working across (almost) all API levels. Is <a href="http://code.google.com/p/iosched/" rel="nofollow noreferrer">Google's solution</a> maybe the best?</p>
  
  <p>Thanks a lot in advance!</p>