I want to create a toolbar like the following image as proposed in the material design guidelines:
I can achieve this via using the toolbar with an relative layout:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Toolbar/>
<LinearLayout android:layout_marginTop="-17dp" />
</RelativeLayout>
I am not sure this is the correct way or not. Any help is appreciated.
You can obtain it using a Toolbar as ActionBar, a CardView and another Toolbar(standalone) inside the Card.
For the Toolbar standalone inside a Card you can use something like this:
Then you can inflate your menu to obtain the icon actions.
For the toolbar used as action bar and the main layout you can use:
option1:
Option2: An extended toolbar (as actionbar) and a CardView as described above playing with margins.
Thanks Gabriele for all the help. Here is working code:
Activity :
Layout XML File:
Make sure your activity theme is extending
Theme.AppCompat.Light.NoActionBar
.Here is what it will look like:
Few things to note: