Have the split ActionBar display twice as many icons

11,193

Solution 1

Looks like I posted too fast, it seems it's not possible.

Duplicates:

Apparently this is not possible. However they did it in gmail/gplus, maybe using a custom view for the bottom part... Still expecting a better answer to this!

Reto Meier's word on this:

I think the problem with splitting the actions between the top and bottom is that it would make it more difficult to perform actions. Actions should be the most important things to do on an Activity -- splitting them between the top and bottom of the screen means users need to look in two places rather than one.

Solution 2

I was also wondering how these apps had icons in both bars, so I decompiled two of them.

What I found is that these two apps didn't implement the ActionBar at all and use custom layouts for both bars. I'm not sure if I can name these apps here, but they are well known apps with 10M+ downloads.

I strongly suggest to go the same way if you don't like the default ActionBar (which have very little room for customization) and create custom layouts instead (not necessary for both bars, it depends on your needs).

It's quite easy to reproduce the split action bar layout. Its height is always 48dp whatever the device is, so a simple LinearLayout or RelativeLayout with a fixed height and some transparent image buttons work very vell. In only 15 minutes you get a fully customizable split action bar.

Share:
11,193
Benoit Duffez
Author by

Benoit Duffez

Updated on June 21, 2022

Comments

  • Benoit Duffez
    Benoit Duffez almost 2 years

    I'd like to have an app layout as the one they used for Gmail. They have the actionbar that has icons (on my device it has the app logo for up navigation, and a custom view for selecting priority inbox/inbox/etc), but there is also some kind of split ActionBar because at the bottom I have several icons (compose, search, labels, etc).

    How could I do this? I have implemented the following ActionBar through this XML:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <item
            android:id="@+id/menu_gps"
            android:icon="@drawable/icone_gps_continu"
            android:showAsAction="always"
            android:title="@string/menu_gps"/>
        <item
            android:id="@+id/menu_sort"
            android:icon="@drawable/icone_liste_chron"
            android:showAsAction="always"
            android:title="@string/menu_liste"/>
        <item
            android:id="@+id/menu_stats"
            android:icon="@drawable/icone_statistiques"
            android:showAsAction="always"
            android:title="@string/menu_stats"/>
        <item
            android:id="@+id/menu_save"
            android:icon="@drawable/icone_terminersortie"
            android:showAsAction="always"
            android:title="@string/menu_save"/>
        <item
            android:id="@+id/menu_search"
            android:icon="@drawable/ic_launcher"
            android:showAsAction="always"
            android:title="@string/menu_search"/>
        <item
            android:id="@+id/menu_photo"
            android:icon="@drawable/icone_enregistrerphoto"
            android:showAsAction="always"
            android:title="@string/menu_photo">
        </item>
        <item
            android:id="@+id/menu_sound"
            android:icon="@drawable/icone_enregistrerson"
            android:showAsAction="always"
            android:title="@string/menu_sound">
        </item>
        <item
            android:id="@+id/menu_settings"
            android:icon="@drawable/icone_parametres"
            android:showAsAction="always"
            android:title="@string/menu_settings">
        </item>
    
    </menu>
    

    And I have of course enabled the split ActionBar by adding android:uiOptions="splitActionBarWhenNarrow" to my <application> tag in the manifest.

    What I get though is an empty "top" ActionBar; and the bottom one is displaying only three icons. I thought I could display like 3-4 icons at the top and 5 at the bottom in portait mode, and all of them at the top in landscape mode.

    Note: even if I'm testing on ICS with my Galaxy Nexus, I'm using ActionBarSherlock in order to provide backward compatibility.