Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ataulm/7d9fb5ef6f085a205c96b3a58bf1f2b0 to your computer and use it in GitHub Desktop.
Save ataulm/7d9fb5ef6f085a205c96b3a58bf1f2b0 to your computer and use it in GitHub Desktop.
AppBarExpander appBarExpander;
...
final RecyclerView view = (RecyclerView) layoutInflater.inflate(R.layout.view_season_page, container, false);
view.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
view.setLayoutManager(new LinearLayoutManager(container.getContext()) {
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
if (!view.isInTouchMode()) {
onScrollWhenInNonTouchMode(dy);
}
return super.scrollVerticallyBy(dy, recycler, state);
}
private void onScrollWhenInNonTouchMode(int dy) {
if (dy > 0) {
appBarExpander.collapseAppBar();
} else {
appBarExpander.expandAppBar();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment