Yes, you should replace ActionBar with a new toolbar
Causes
1) It looks modern and follows a new material design
2) Unlike the action bar, the toolbar is not part of the window decoration. You define it and place it just like any other widget ... so you have the freedom to place it anywhere in the parent layout.
3) You have the freedom to place any widget inside the toolbar.
4) You can define several toolbars.
EDIT
What I meant, you can place other widgets (views) inside the toolbar.
Create a separate layout file for the toolbar (useful for reuse). In my case, the file name is main_toolbar .
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:App="http://schemas.android.com/apk/res-auto" xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" App:theme="@style/ToolbarColoredBackArrow" android:layout_height="56dp" android:background="@color/primary_color" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/drawer_fntsize" android:text="Title" android:id="@+id/lbl_title" android:textColor="@color/title_text_color" android:layout_gravity="center" /> </android.support.v7.widget.Toolbar>
Then include this toolbar in your main layout, for example,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:id="@+id/toolbar" layout="@layout/main_toolbar"/> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar" />
As you can see in this example, I placed the TextView inside the toolbar
Shane Ekanayake Apr 23 '15 at 6:04 2015-04-23 06:04
source share