Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Updated 22 December 2016
In this blog, I showed how to achieve hiding/showing Toolbar when the list is scrolling by Design Support Library and we don’t need to do it manually.
I will show how to use CoordinatorLayout and create a simple Behavior to hiding/show Toolbar when list scrolls up/down.
In below example, I will use a CoordinatorLayout as a parent Layout and use a ToolBar with AppBarLayout. And a recylerView which will be scrolled.
So,
Step 1: Create a ToolBar separately for use it in an entire application
toolbar.xml
toolbar: – A Toolbar is a generalized form of action bars for use within application layouts.
action bars
Set this flag to your ToolBar.
this app:layout_scrollFlags attribute, performs scroll events in the RecyclerView trigger changes inside views declared within AppBarLayout.
app:layout_scrollFlags
AppBarLayout.
enterAlways: The view will become visible when scrolling up.
enterAlways
snap: Using this option will determine what to do when a view only has been partially reduced.
snap
Step 2: Create the other XML file where you want to apply hide/show property
hide_show.xml
CoordinatorLayout: – CoordinatorLayout has the ability to achieve many of the Google’s Material Design scrolling effects.
AppBarLayout: – AppBarLayout is a vertical LinearLayout which performs many of the features of material designs app bar concept, namely scrolling gesticulation.
LinearLayout
recylerView: – Android now give the RecyclerView widget, a new and enhanced view group for displaying very large collections of data.
Set the behavior in recycler view
We have to define AppBarLayout and the View that will be scrolled.
Add a app:layout_behavior to a RecyclerView or any other View prepared of nested scrolling such as NestedScrollView.
app:layout_behavior
By Adding the above property in your XML, you can achieve the ability to hide and showing toolbar while scrolling.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.