android - How to make hide/show toolbar when our list scrolling to the top -


how make hide/show toolbar when our list scrolling top, knowing toolbar view described inside activity_main.xml recyclerview described in fragmet nomed fragment_main.xml

sorry english :)

since activity has toolbar within content view starting fragment, can hold of fragment.

mainactivity mainactivity = (mainactivity)getactivity(); 

i recommend doing method in mainactivity:

public void showtoolbar(boolean show) {      // if have toolbar private member of mainactivity     toolbar.setvisiblity(show ? view.visible : view.gone);      // can     if (show) {         getsupportactionbar().show();     }     else {         getsupportactionbar().hide();     } } 

and when want hide fragment, call it:

((mainactivity)getactivity()).showtoolbar(false); 

to make ui change more smooth, recommend translating instead of instantly hiding it. take @ top answer here inspiration:

android lollipop toolbar: how hide/show toolbar while scrolling?

if don't know how take care of when show or hide via scroll logic, take @ library handles lot , gives examples:

https://github.com/ksoichiro/android-observablescrollview


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -