I've got a split ActionBar, and I'm trying to add functionality almost identical to google play's 'Now playing'..
I can get menu items to appear at the bottom of the screen, using the onCreateOptionsMenu, but I can't seem to get a custom view to appear at the bottom of the screen when using actionBar.setCustomView. The custom view just sits underneath the top ActionBar.
Does anyone know how to force the customview to the bottom, or to add custom views to the onCreateOptionsMenu?
Here are the snippets of my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
//Custom view to add
actionBar.setCustomView(R.layout.albumitem);
//This view shows up just under the top actionbar at the moment,
despite menu items being at the bottom
The menu options code: (These are showing down the bottom where I'd like my custom view to be)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.option_menu, menu);
return (super.onCreateOptionsMenu(menu));
}
I believe that the now playing menu at the bottom of the google play music app is a custom view inside a split action bar:
I've done a solution based on yours, including custom layout on top + custom layout on bottom + title/subtitle + home icon. Here is the code:
ab_custom_layout.xml
menu_including_layout.xml
ab_bottom_layout.xml
Code works perfect for me. I can see the split ActionBar when my tablet is on portrait. On landscape it is wide enough to store all the items on the top.
Hope it helps
So I managed to find a dirty solution to this.. Well, dirty in my amateurish opinion..
In the oncreateOptionsMenu, I've inflated a menu called option_menu like so:
And in the xml for that option_menu item, I've implemented an actionViewClass, and in this case I've used relative layout (I'm guessing I could've just used View..?):
So then I inflated an xml layout, and added it to the layout_item defined in my menu:
Please feel free to edit/enhance this answer as you see fit.