How to create a Double toolbar?

1

I researched google, but I never found a way to make a double toolbar (material design) like the one in the image:

Everywhere I've been show just how to make the toolbar simple. If it is easier, just direct me to what I should look for.

    
asked by anonymous 27.01.2016 / 21:23

1 answer

2

If you are using Toolbar then the easiest way to have a Extended Toolbar is to use a value of layout_height other than ?attr/actionBarSize (which is the default value).

In this Chris Banes , he recommends using a 128dp size to adhere to the Material Design spec.

Following the hint, you would have something like:

<Toolbar
    android:id="@+id/toolbar"
    android:layout_height="128dp"
    android:layout_width="match_parent"
    android:minHeight="?android:attr/actionBarSize"
    android:background="?android:attr/colorPrimary"
    android:gravity="bottom" />

To get this full layout, I recommend something like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    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"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primary"
        android:minHeight="128dp"
        android:gravity="bottom" />

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="?attr/actionBarSize"
        android:layout_marginStart="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:minHeight="364dp">

    </android.support.v7.widget.CardView>
</FrameLayout>

Looking like this:

Of course you need to adapt to your case, but the beginning is there.

    
27.01.2016 / 22:41