Creating an actionbar or toolbar with custom xml and a drawertoggle

427 views Asked by At

How can I create a toolbar/actionbar that combines the default actiondrawertoggle button (with the burger-arrow animation) with an edittext and a simple button like this?

enter image description here

1

There are 1 answers

0
SilentKnight On

Toolbar is a ViewGroup, so, you can use a Toolbar as a FrameLayout.

Here is a simple example, take a look at it:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_appcompat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
    <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    //customize your toolbar content layout here.
    </LinearLayout >
</android.support.v7.widget.Toolbar>

Hope you'll be inspired.