Created
March 18, 2016 14:49
-
-
Save ricdex/fae1c5b66da9baee74e5 to your computer and use it in GitHub Desktop.
Un atributo (margin, padding) animado en el tiempo para android
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
ValueAnimator varl = ValueAnimator.ofInt(150); | |
varl.setDuration(400); | |
varl.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator animation) { | |
float d = mRecyclerView.getContext().getResources().getDisplayMetrics().density; | |
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mRecyclerView.getLayoutParams(); | |
params.bottomMargin = (int) (((Integer) animation.getAnimatedValue() - 150) * d); | |
mRecyclerView.setLayoutParams(params); | |
} | |
}); | |
varl.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment