-
-
Save robsn/3982a3065a1c2db3b05e9a7c0d69cff3 to your computer and use it in GitHub Desktop.
Hide Show Scrolling FAB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dashboard.addOnScrollListener(object : RecyclerView.OnScrollListener() { | |
override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) { | |
if (dy > 0 || dy < 0 && fab.isShown) { | |
fab.hide() | |
} | |
super.onScrolled(recyclerView, dx, dy) | |
} | |
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) { | |
if (newState == RecyclerView.SCROLL_STATE_IDLE) { | |
fab.show() | |
} | |
super.onScrollStateChanged(recyclerView, newState) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment