Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split action bar on Android 5.0 (Lollipop)

Does anybody know if the split action bar when narrow feature was removed from Android 5.0? It seems that it does not have any effect on the layout anymore.

like image 262
Florian Avatar asked Oct 30 '14 18:10

Florian


People also ask

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.

Where is the action bar on my android phone?

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.

How do I add an action bar?

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.


Video Answer


2 Answers

Since this question was not really answered before...

Does anybody know if the split action bar when narrow feature was removed from Android 5.0?

Yes, it was, though that change is not documented outside of the issue tracker entry itself.

like image 133
CommonsWare Avatar answered Oct 21 '22 04:10

CommonsWare


As said you cannot split the action bar, although you can achieve a even better result with the Toolbar.

   Toolbar toolbarBottom = (Toolbar) findViewById(R.id.toolbar_bottom);
    toolbarBottom.inflateMenu(R.menu.menu_bottom);
    toolbarBottom.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            //your code
            return false;
        }
    });

It's important to say that this feature is backwards compatible with the appcompat support

compile "com.android.support:appcompat-v7:21.0.+"

You'll also need to declare the toolbar in your layout.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_bottom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"/>

    <LinearLayout
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="?attr/actionBarSize"
    android:layout_above="@id/toolbar"
    android:layout_below="@id/toolbar_bottom" />
</LinearLayout> 

like image 39
Tin Megali Avatar answered Oct 21 '22 05:10

Tin Megali