How to hide/show toolbar in response to scrolling on Android

The Toolbar is a new android widget, introduced in API 21 (Lollipop), designed and intended to replace the ActionBar. The ActionBar was introduced in API 11 (Honeycomb), to appear at the top of an activity’s window. The Toolbar, on the other hand is more powerful than the ActionBar. For example, the Toolbar can be placed at any arbitrary point in the activity layout hierarchy. There can even be multiple Toolbars in a single Activity.