Created
March 2, 2017 13:19
-
-
Save vogella/51ce24171a34c2f6f68eaad570358fff to your computer and use it in GitHub Desktop.
This file contains 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
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrollStateChanged(RecyclerView recyclerView, int newState) { | |
if (newState == RecyclerView.SCROLL_STATE_IDLE) { | |
final View tb = getActivity().findViewById(R.id.toolbar); | |
tb.animate() | |
.translationY(0) | |
.setInterpolator(new LinearInterpolator()) | |
.setDuration(180) | |
.setListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationStart(Animator animation) { | |
tb.setVisibility(View.VISIBLE); | |
} | |
}); | |
} else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { | |
final View tb = getActivity().findViewById(R.id.toolbar); | |
tb.animate() | |
.translationY(tb.getHeight()) | |
.setInterpolator(new LinearInterpolator()) | |
.setDuration(180) | |
.setListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
tb.setVisibility(View.GONE); | |
} | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment