As stated in this post (click) android:uiOptions="splitActionBarWhenNarrow"
has been removed in Lollipop. Though this is not that big of a deal since you can simply use two Toolbars
- one at the top and one at the bottom.
Following some basic example code:
Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_bottom"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="?attr/colorPrimary"
android:layout_alignParentBottom="true"
android:minHeight="?attr/actionBarSize" />
<LinearLayout
android:layout_below="@id/toolbar_top"
android:layout_above="@id/toolbar_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Code
private void initToolbars() {
Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
setSupportActionBar(toolbarTop);
Toolbar toolbarBottom = (Toolbar) findViewById(R.id.toolbar_bottom);
toolbarBottom.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()){
case R.id.action_settings:
// TODO
break;
// TODO: Other cases
}
return true;
}
});
// Inflate a menu to be displayed in the toolbar
toolbarBottom.inflateMenu(R.menu.menu_main);
}
Result
Note: Handling when to show two Toolbars or just one is something you have to do manually
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…