Skip to content

Instantly share code, notes, and snippets.

@leelei
Last active August 29, 2015 14:11
Show Gist options
  • Save leelei/f9c2750d319e9f1724d9 to your computer and use it in GitHub Desktop.
Save leelei/f9c2750d319e9f1724d9 to your computer and use it in GitHub Desktop.
public class AnimatorUtils {
public final static int COLOR_ANIMATION_DURATION = 1000;
public final static int DEFAULT_DELAY = 0;
public static void animateViewColor (View v, int startColor, int endColor) {
ObjectAnimator animator = ObjectAnimator.ofObject(v, "backgroundColor",
new ArgbEvaluator(), startColor, endColor);
animator.setInterpolator(new PathInterpolator(0.4f,0f,1f,1f));
animator.setDuration(COLOR_ANIMATION_DURATION);
animator.start();
}
public static void configuredHideYView (View v) {
v.setScaleY(0);
v.setPivotY(0);
}
public static ViewPropertyAnimator hideViewByScaleXY(View v) {
return hideViewByScale(v, DEFAULT_DELAY, 0, 0);
}
public static ViewPropertyAnimator hideViewByScaleY(View v) {
return hideViewByScale(v, DEFAULT_DELAY, 1, 0);
}
public static ViewPropertyAnimator hideViewByScalyInX(View v) {
return hideViewByScale(v, DEFAULT_DELAY, 0, 1);
}
private static ViewPropertyAnimator hideViewByScale (View v, int delay, int x, int y) {
ViewPropertyAnimator propertyAnimator = v.animate().setStartDelay(delay)
.scaleX(x).scaleY(y);
return propertyAnimator;
}
public static ViewPropertyAnimator showViewByScale (View v) {
ViewPropertyAnimator propertyAnimator = v.animate().setStartDelay(DEFAULT_DELAY)
.scaleX(1).scaleY(1);
return propertyAnimator;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment