3

I am trying to use the ui option: splitActionBarWhenNarrow in my application, but it seems as I am experiencing an unwanted behaviour.

EDIT: Attaching a small gist with some more code.

This is the code in the manifest for the activity:

<activity
        android:name="com.example.HomeActivity"
        android:uiOptions="splitActionBarWhenNarrow"
        android:label="@string/app_name" >

That is the only activity I intent to change the ActionBar style on. In the activity code, I have disabled the actionBar title and icon, so the tabs can merge as the only top action bar.

    private void setupActionBar() {
    final ActionBar mActionBar = getActionBar();

    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);

    mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_one).setTabListener(this));
    mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_two).setTabListener(this));
    mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_three).setTabListener(this));
    }   

This worked well; however, it seems as if the bottom action bar is not going all the way to the bottom of the activity, but rather just below the top action bar.

Here is what it looks like after the code I wrote, How can I get it to go all the way down, like for instance on the Android's stock messaging app?

Edit, reattaching images.

Here's how it currently look with the code above, and here's how I want it to look.

daniel_c05
  • 11,438
  • 17
  • 60
  • 78
  • "like for instance on the Android's stock messaging app?" -- it is quite possible that those are not action bar tabs, but rather something else, such as `PagerTabStrip`. That being said, since "Android's stock messaging app" is open source, you could always look at it to see what they do differently. I too would expect your code to behave as you are seeking, not as you are seeing. – CommonsWare Feb 03 '13 at 12:41
  • The Stock messaging app does use the [actionBar](https://github.com/android/platform_packages_apps_mms/blob/master/src/com/android/mms/ui/ConversationList.java) **line 147**, which is [split when narrow](https://github.com/android/platform_packages_apps_mms/blob/master/AndroidManifest.xml) **Line 57** – daniel_c05 Feb 03 '13 at 12:52
  • It's kind of a funky thing huh? Wondering where the problem maybe. – daniel_c05 Feb 03 '13 at 12:53
  • I have the same problem... Hopefully someone knows how to fix this... – Alioooop Feb 05 '13 at 12:39
  • Yes, much like the gmail app, the action bar is split and most actions are on the bottom of the layout. – daniel_c05 Feb 16 '13 at 14:46
  • Are you sure you've disabled the title, because it's quite obviously there in your screenshot? This is the first time I'm seeing this behaviour but what's obvious is that the tabs are failing to merge with the top bar. Perhaps one of your fragments is reenabling the title? – Delyan Feb 18 '13 at 12:23
  • Even if the tabs aren´t merged with title, which I know they´re not, because on that last screenshot I did not call mActionBar.setDisplayShowHomeEnabled(false); or mActionBar.setDisplayShowTitleEnabled(false);, the action bar should locate a section of it on the bottom of the layout. – daniel_c05 Feb 18 '13 at 13:54
  • @Delyan I updated the screenshot to show the action bar actually merged :) – daniel_c05 Feb 18 '13 at 14:11
  • You're not doing anything fancy to add that list, are you? Also, are you setting up your action bar before or after setContentView? – Delyan Feb 18 '13 at 15:18
  • To add the listview inside the Fragment? Not at all, what would be your definition of Fancy? And yes, I set up the actionbar **after** calling setContentView. Here's a small overview of the onCreate method: https://gist.github.com/daniel-c05/48d6b204aa18986542ff – daniel_c05 Feb 18 '13 at 17:16
  • If it makes you feel better, [a bug report was filed](http://code.google.com/p/android/issues/detail?id=36191). If there's no title, it stacks the action bar below the tabs. In your case, it doesn't need to move them to the bottom, because at that point it has plenty of room, and isn't considered "narrow". They say it's an "intended UX decision". One user shows a workaround, but I haven't tested it to see if that will work for you. – Geobits Feb 19 '13 at 19:18
  • Seems that this post can help you http://stackoverflow.com/questions/8465258/how-can-i-force-the-action-bar-to-be-at-the-bottom-in-ics – Ashish Singh Feb 20 '13 at 15:22
  • What API level are you using? – Phil Feb 21 '13 at 16:41
  • Targetting 17, min is 14. – daniel_c05 Feb 22 '13 at 02:50
  • What blows is that I made a sample project, I didn´t even touch the action bar settings, all I did was change the manifest and it works there.. :( – daniel_c05 Feb 23 '13 at 13:16

1 Answers1

0

I have posted a working demo app with tabs and an actiobar at the buttom
Here

Check it out and hope it helps

Achachi
  • 15
  • 1
  • 5
  • I'm sorry but if you read the question I am already using the same code, and it still isn't working. Thanks for trying though – daniel_c05 Feb 23 '13 at 12:59