Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force the Action Bar to be at the bottom in ICS?

Ice Cream Sandwich (Android 4.0) adds the option of having the Action Bar at the bottom of the screen on phones, and that's something I'd love to have in an application of mine. The docs mention uiOptions="splitActionBarWhenNarrow" for when you want something, i.e. tabs, at the top and Action Bar shortcuts at the bottom. I've tried adding the line in the application manifest, as described in the docs, but haven't got it working thus far.

Here's an example:

enter image description here

Also, I noticed that on my Galaxy Nexus, which runs ICS, that the messaging application has the Action Bar the bottom and nothing but the title on the top, so it must be possible to somehow force the Action Bar to be at the bottom.

Any ideas?

like image 717
Michell Bak Avatar asked Dec 11 '11 15:12

Michell Bak


People also ask

How do I customize my action bar?

This example demonstrate about how to create a custom action bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I hide action bars?

If you want to hide Action Bar throughout the app (Activities, Fragments) everywhere, you can simply navigate to res > values > styles.


2 Answers

I've tried adding the line in the application manifest, as described in the docs, but haven't got it working thus far.

It worked for me in this sample project. Here is the manifest:

<?xml version="1.0" encoding="utf-8"?> <manifest package="com.commonsware.android.actionbarbc"           xmlns:android="http://schemas.android.com/apk/res/android">    <application android:hardwareAccelerated="true"                android:icon="@drawable/cw"                android:label="@string/app_name">     <activity android:label="@string/app_name"               android:name=".InflationDemo"               android:uiOptions="splitActionBarWhenNarrow">       <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.LAUNCHER" />       </intent-filter>     </activity>   </application>   <uses-sdk android:minSdkVersion="4"             android:targetSdkVersion="11" />   <supports-screens android:anyDensity="true"                     android:largeScreens="true"                     android:normalScreens="true"                     android:smallScreens="true"                     android:xlargeScreens="true" /> </manifest> 

Also, I noticed that on my Galaxy Nexus, which runs ICS, that the messaging application has the Action Bar the bottom and nothing but the title on the top, so it must be possible to somehow force the Action Bar to be at the bottom.

If you are referring to the conversation list, that is the ActionBar at the top and bottom, using splitActionBarWhenNarrow and the following setup code:

private void setupActionBar() {     ActionBar actionBar = getActionBar();      ViewGroup v = (ViewGroup)LayoutInflater.from(this)         .inflate(R.layout.conversation_list_actionbar, null);     actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,             ActionBar.DISPLAY_SHOW_CUSTOM);     actionBar.setCustomView(v,             new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,                     ActionBar.LayoutParams.WRAP_CONTENT,                     Gravity.CENTER_VERTICAL | Gravity.RIGHT));      mUnreadConvCount = (TextView)v.findViewById(R.id.unread_conv_count); } 
like image 137
CommonsWare Avatar answered Sep 21 '22 20:09

CommonsWare


I'm using ActionBarSherlock and I had a similar problem. I solved it by putting android:uiOptions="splitActionBarWhenNarrow" within the <activity> tag, rather than the <application> tag.

For example, this worked:

<activity android:name=".my.Activity"            android:uiOptions="splitActionBarWhenNarrow"/> 

and this didn't work:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"           package="com.slowchop.etc"           android:uiOptions="splitActionBarWhenNarrow"> 
like image 36
gak Avatar answered Sep 17 '22 20:09

gak