Skip to content

Instantly share code, notes, and snippets.

@nesterchung
Created May 29, 2018 06:22
Show Gist options
  • Save nesterchung/7e0d752af081dd57da9e0a57c85bb3a7 to your computer and use it in GitHub Desktop.
Save nesterchung/7e0d752af081dd57da9e0a57c85bb3a7 to your computer and use it in GitHub Desktop.
drawerlayout scroll to top
val toggle = object : ActionBarDrawerToggle(this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
override fun onDrawerClosed(drawerView: View?) {
super.onDrawerClosed(drawerView)
val recyclerView = navigationView.getChildAt(0) as RecyclerView
recyclerView.layoutManager.scrollToPosition(0)
}
}
drawer_layout.addDrawerListener(toggle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment