Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/Pi09V.png" alt="enter image description here"></p> <p>This is pretty much as close as you'll get if you want to use the <code>ActionBar</code> APIs. I'm not sure you can place a colorstrip above the <code>ActionBar</code> without doing some weird <code>Window</code> hacking, it's not worth the trouble. As far as changing the <code>MenuItems</code> goes, you can make those tighter via a style. It would be something like this, but I haven't tested it.</p> <pre><code>&lt;style name="MyTheme" parent="android:Theme.Holo.Light"&gt; &lt;item name="actionButtonStyle"&gt;@style/MyActionButtonStyle&lt;/item&gt; &lt;/style&gt; &lt;style name="MyActionButtonStyle" parent="Widget.ActionButton"&gt; &lt;item name="android:minWidth"&gt;28dip&lt;/item&gt; &lt;/style&gt; </code></pre> <p><strong>Here's how to inflate and add the custom layout to your <code>ActionBar</code>.</strong></p> <pre><code> // Inflate your custom layout final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate( R.layout.action_bar, null); // Set up your ActionBar final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(actionBarLayout); // You customization final int actionBarColor = getResources().getColor(R.color.action_bar); actionBar.setBackgroundDrawable(new ColorDrawable(actionBarColor)); final Button actionBarTitle = (Button) findViewById(R.id.action_bar_title); actionBarTitle.setText("Index(2)"); final Button actionBarSent = (Button) findViewById(R.id.action_bar_sent); actionBarSent.setText("Sent"); final Button actionBarStaff = (Button) findViewById(R.id.action_bar_staff); actionBarStaff.setText("Staff"); final Button actionBarLocations = (Button) findViewById(R.id.action_bar_locations); actionBarLocations.setText("HIPPA Locations"); </code></pre> <p><strong>Here's the custom layout:</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:enabled="false" android:orientation="horizontal" android:paddingEnd="8dip" &gt; &lt;Button android:id="@+id/action_bar_title" style="@style/ActionBarButtonWhite" /&gt; &lt;Button android:id="@+id/action_bar_sent" style="@style/ActionBarButtonOffWhite" /&gt; &lt;Button android:id="@+id/action_bar_staff" style="@style/ActionBarButtonOffWhite" /&gt; &lt;Button android:id="@+id/action_bar_locations" style="@style/ActionBarButtonOffWhite" /&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>Here's the color strip layout: To use it, just use <code>merge</code> in whatever layout you inflate in <code>setContentView</code>.</strong></p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="@dimen/colorstrip" android:background="@android:color/holo_blue_dark" /&gt; </code></pre> <p><strong>Here are the <code>Button</code> styles:</strong></p> <pre><code>&lt;style name="ActionBarButton"&gt; &lt;item name="android:layout_width"&gt;wrap_content&lt;/item&gt; &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt; &lt;item name="android:background"&gt;@null&lt;/item&gt; &lt;item name="android:ellipsize"&gt;end&lt;/item&gt; &lt;item name="android:singleLine"&gt;true&lt;/item&gt; &lt;item name="android:textSize"&gt;@dimen/text_size_small&lt;/item&gt; &lt;/style&gt; &lt;style name="ActionBarButtonWhite" parent="@style/ActionBarButton"&gt; &lt;item name="android:textColor"&gt;@color/white&lt;/item&gt; &lt;/style&gt; &lt;style name="ActionBarButtonOffWhite" parent="@style/ActionBarButton"&gt; &lt;item name="android:textColor"&gt;@color/off_white&lt;/item&gt; &lt;/style&gt; </code></pre> <p><strong>Here are the colors and dimensions I used:</strong></p> <pre><code>&lt;color name="action_bar"&gt;#ff0d0d0d&lt;/color&gt; &lt;color name="white"&gt;#ffffffff&lt;/color&gt; &lt;color name="off_white"&gt;#99ffffff&lt;/color&gt; &lt;!-- Text sizes --&gt; &lt;dimen name="text_size_small"&gt;14.0sp&lt;/dimen&gt; &lt;dimen name="text_size_medium"&gt;16.0sp&lt;/dimen&gt; &lt;!-- ActionBar color strip --&gt; &lt;dimen name="colorstrip"&gt;5dp&lt;/dimen&gt; </code></pre> <p>If you want to customize it more than this, you may consider not using the <code>ActionBar</code> at all, but I wouldn't recommend that. You may also consider reading through the <a href="http://developer.android.com/design/index.html" rel="noreferrer">Android Design Guidelines</a> to get a better idea on how to design your <code>ActionBar.</code> </p> <p>If you choose to forgo the <code>ActionBar</code> and use your own layout instead, you should be sure to add action-able <code>Toasts</code> when users long press your "MenuItems". This can be easily achieved <a href="https://gist.github.com/romannurik/3982005" rel="noreferrer">using this Gist</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload