Skip to content

Instantly share code, notes, and snippets.

@ricdex
Created March 18, 2016 14:49
Show Gist options
  • Save ricdex/fae1c5b66da9baee74e5 to your computer and use it in GitHub Desktop.
Save ricdex/fae1c5b66da9baee74e5 to your computer and use it in GitHub Desktop.
Un atributo (margin, padding) animado en el tiempo para android
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