Closed douglasscriptore closed 9 years ago
Hi,
Call hide() method in your scroll listener.
To show it again, call show() method.
Best wishes, Shell Software Inc. On 8 May 2015 19:00, "Douglas Scriptore" notifications@github.com wrote:
Hello ! How do I hide FAB to scroll the page ?
Thank you
— Reply to this email directly or view it on GitHub https://github.com/shell-software/fab/issues/24.
I'm using RecyclerView used the setOnScrollLister if anyone has doubts below is the code I used .
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
float y = recyclerView.getY();
if(dy == 0){
fab.show();
}else if (y > dy) {
fab.show();
}else{
fab.hide();
}
}
});
I'm not sure whether this should work correctly.
getY() is actually an inherited method from android.view.View class, which returns the visual position of the RecyclerView.
In order to get this work, I suggest:
The sample code may look like this:
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int scrollLimit = 4 // convert this value to density-dependent pixel
boolean scrollLimitReached = Math.abs(dy) >= scrollLimit;
if (scrollLimitReached) {
boolean scrollUp = dy >= 0;
if (scrollUp) {
actionButton.show();
} else {
actionButton.hide();
}
}
}
Hope this helps. Good luck
wow great, thanks.
Issue solved
Hello ! How do I hide FAB to scroll the page ?
Thank you