If an Android ActionBar is split into a top and a bottom portion using android:uiOptions="splitActionBarWhenNarrow"
in the Manifext.xml
,
is there a way to force some of the actions to be displayed in the top portion instead of having them all at the bottom?
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.
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.
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.
There's no standard way of doing this. That said, the Action Bar custom view will appear in the upper bar, so you can just use that. You will lose some of the extras (toasts on long press), so you'll have to implement them yourself. That said, of you're using ActionBarSherlock, all the layouts and styles for a normal button are there, so you can just use those.
Yes! You can continue to use android:uiOptions="splitActionBarWhenNarrow"
in your Manifest.xml.
You just also need to set:
// set the actionbar to use the custom view
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
//set the custom view to use
getActionBar().setCustomView(R.layout.custom_action_bar_top);
Where R.layout.custom_action_bar_top
would be a view that has all the buttons you wish to appear in the top action bar.
All the menu items that you want at the bottom, should be added as usual in the onCreateOptionsMenu
method of your activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With