Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ActionBar Will Not Split On Device

I know there have been many ActionBar questions but they don't seem to address my problem. I am able to spit the ActionBar in my emulator, but when I run my program on my device (Nexus 7 portrait mode) the ActionBar will not split. All the icons 'pile up' on top, even my tabs create a drop down list. I have tried to force the issue by making the menu items names extremely long and I do have them set to: android:showAsAction="always|withText". Just to be sure, I have taken sample code, ran it on the emulator seen it work and then put it on my device to no avail. Here's my manifest:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyTheme">
    <activity
        android:name=".MainActivity"
        android:uiOptions="splitActionBarWhenNarrow"
        android:label="@string/title_activity_main">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I have scoured the web but cannot find a solution. Any help is appreciated.

like image 820
Tony D Avatar asked Nov 28 '12 13:11

Tony D


People also ask

What is split action bar?

You can adapt to such changes by using split action bars, which allow you to distribute action bar content across multiple bars located below the main action bar or at the bottom of the screen. Split action bar showing action buttons at the bottom of the screen in vertical orientation.

What is android ActionBar?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button. In general an ActionBar consists of the following four components: App Icon: App branding logo or icon will be displayed here.

What is app bar android?

The app bar, also known as the action bar, is one of the most important design elements in your app's activities, because it provides a visual structure and interactive elements that are familiar to users.

How do I add items to Action Bar?

All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.


1 Answers

According to this SO item, the ActionBar is only splitted when the available width is less than 480dp. According to this article of Google's Dianne Hackborn however, the portrait width of the Nexus 7 is 600dp. So that's the reason there's no splitting.

I agree with you, that the splitting should depend on the relation between available space and items to be shown, not on the available space alone.

like image 119
Ridcully Avatar answered Sep 18 '22 03:09

Ridcully