Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Split Action Bar with Action Items on the top and bottom?

Is there a way to specify some action items to the top part of the Split Action Bar while the others go to the bottom? Or is it all or nothing, whereby all the action items go to the bottom part of the split only?

enter image description here

like image 304
Ryan R Avatar asked Dec 20 '11 06:12

Ryan R


People also ask

How can I customize my action bar in Android?

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.

What is split action bar in Android?

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.


2 Answers

This is currently not possible.

See the response directly from Android developers Reto Meier and Roman Nurik during the Android Developer Office Hours: http://youtu.be/pBmRCBP56-Q?t=55m50s

like image 182
Ryan R Avatar answered Sep 22 '22 03:09

Ryan R


To solve this I used a custom view as my action bar:

@Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.main);      ActionBar actionBar = getActionBar();     actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);      View view = View.inflate(getApplicationContext(), R.layout.actionbar,             null);     actionBar.setCustomView(view);  } 

and then for the bottom bar I inflated my menu view or whatever you want to appear at bottom:

 @Override public boolean onCreateOptionsMenu(Menu menu) {     getMenuInflater().inflate(R.menu.browser_main, menu);     RelativeLayout relativeLayout = (RelativeLayout) menu.findItem(             R.id.layout_item).getActionView();      View inflatedView = getLayoutInflater().inflate(             R.layout.media_bottombar, null);      relativeLayout.addView(inflatedView);      return true; } 

In the Android Manifest, I also include (android:uiOptions="splitActionBarWhenNarrow") like this:

<application     android:allowBackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/AppTheme"     android:uiOptions="splitActionBarWhenNarrow" > .... 
like image 20
roomtek Avatar answered Sep 24 '22 03:09

roomtek