List of usage examples for android.animation ValueAnimator start
@Override public void start()
From source file:Main.java
public static void expand(View summary) { //set Visible summary.setVisibility(View.VISIBLE); final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); summary.measure(widthSpec, 300);// w w w .ja v a 2s . c o m ValueAnimator mAnimator = slideAnimator(0, 300, summary); mAnimator.start(); }
From source file:Main.java
public static synchronized void animateScaleUp(View v, float targetScale) { float currentScaleX = v.getScaleX(); float currentScaleY = v.getScaleY(); PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofFloat(View.SCALE_X, currentScaleX, targetScale); PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofFloat(View.SCALE_Y, currentScaleY, targetScale); ValueAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(v, scaleXHolder, scaleYHolder); scaleAnimator.start(); }
From source file:Main.java
public static synchronized void animateScaleDown(View v, float targetScale) { float currentScaleX = v.getScaleX(); float currentScaleY = v.getScaleY(); PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofFloat(View.SCALE_X, currentScaleX, targetScale); PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofFloat(View.SCALE_Y, currentScaleY, targetScale); ValueAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(v, scaleXHolder, scaleYHolder); scaleAnimator.start(); }
From source file:Main.java
public static void start(ValueAnimator... animators) { for (ValueAnimator animator : animators) { final float fraction = animator.getAnimatedFraction(); if (fraction < 1.0f) { animator.start(); }/*from w ww. j a va 2 s . c om*/ } }
From source file:Main.java
public static void animateColor(View view, int colorFrom, int colorTo) { final View mView = view; final ValueAnimator va = ObjectAnimator.ofArgb(colorFrom, colorTo); va.setDuration(300);/*from ww w .ja v a2 s .c om*/ va.addUpdateListener(animation -> mView.setBackgroundColor((Integer) animation.getAnimatedValue())); va.start(); }
From source file:Main.java
/** * Update text color with animation/*from www. ja v a 2 s . c om*/ */ public static void updateTextColor(final TextView textView, int fromColor, int toColor) { ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); colorAnimation.setDuration(150); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); }
From source file:Main.java
/** * Update text color with animation//from w w w . j a va2 s .co m */ public static void updateViewBackgroundColor(final View view, int fromColor, int toColor) { ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); colorAnimation.setDuration(150); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); }
From source file:Main.java
/** * Update alpha//w w w.j a va2s . com */ public static void updateAlpha(final View view, float fromValue, float toValue) { ValueAnimator animator = ValueAnimator.ofFloat(fromValue, toValue); animator.setDuration(150); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); view.setAlpha(animatedValue); } }); animator.start(); }
From source file:Main.java
public static void changeTextSize(final TextView textView, float from, float to) { ValueAnimator textSizeChangeAnimator = ValueAnimator.ofFloat(from, to); textSizeChangeAnimator.setDuration(150); textSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w . j a v a 2 s . com*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) valueAnimator.getAnimatedValue()); } }); textSizeChangeAnimator.start(); }
From source file:Main.java
@SuppressWarnings("deprecation") public static void clipDrawable(final View image, Drawable drawable, boolean isActivated) { if (drawable == null) { return;//from w w w.j av a 2s . com } if (isActivated) { final ClipDrawable scaleDrawable = new ClipDrawable(drawable, Gravity.CENTER, ClipDrawable.HORIZONTAL | ClipDrawable.VERTICAL); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { image.setBackground(scaleDrawable); } else { image.setBackgroundDrawable(scaleDrawable); } image.setBackgroundDrawable(scaleDrawable); ValueAnimator animator = ValueAnimator.ofInt(0, 10000); animator.setDuration(200); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleDrawable.setLevel((Integer) animation.getAnimatedValue()); } }); animator.start(); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { image.setBackground(null); } else { image.setBackgroundDrawable(null); } } }