With the release of Android 5.0 a.k.a Lollipop new features were added to the android ecosystem,but the top most notable feature of android 5.0 is the Material Design Spec.
The most notable feature for any android app is is Toolbar widget.
This is a generalization of the ActionBar pattern but gives you much more control and flexibility in using it. Toolbar is a view in your hierarchy just like any other, making it easier to interleave with the rest of your views, animate, react to scroll events.
How to use.
If you’re using Gradle then the first thing to do is to add appcompat as a dependency in your build.gradle:
There are two ways for using Toolbar either standalone or Action bar. I will discuss using it as an Aciton bar.
Firstly the Activity should extend from ActionBarActivity but note to use import it from appcompact-v7.
Change the values/themes.xml:
You need to create a Toolbar instance, usually via your layout XML:
Then add the toolbar layout to your activity
layout as:
Final step is to to set your Toolbar as your action bar in the Activity.java:
This is the Result:
In my next post i will talk about using toolbar as standalone.