List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:com.xujun.contralayout.utils.AnimatorUtil.java
public static void show(final View view, int start, int end) { final int height = view.getHeight(); final ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*w w w.j ava2s.c o m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { int value = (Integer) animator.getAnimatedValue(); Log.i(TAG, "onAnimationUpdate: value=" + value); view.setTop(value); view.setBottom(value + height); } }); view.setVisibility(View.VISIBLE); animator.setDuration(200); animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); animator.start(); }
From source file:com.jerrellmardis.amphitheatre.util.Utils.java
public static void animateColorChange(final View view, int colorFrom, int colorTo) { ValueAnimator valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w .ja va 2 s .c o m public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); valueAnimator.start(); }
From source file:com.xujun.contralayout.utils.AnimatorUtil.java
public static void tanslation(final View view, float start, float end) { final ValueAnimator animator = ValueAnimator.ofFloat(start, end); view.setVisibility(View.VISIBLE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w. j a v a 2 s . c o m public void onAnimationUpdate(ValueAnimator valueAnimator) { Float value = (Float) animator.getAnimatedValue(); Log.i(TAG, "tanslation: value=" + value); view.setTranslationY(value); } }); animator.setDuration(200); animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); animator.start(); }
From source file:com.xujun.contralayout.utils.AnimatorUtil.java
public static void showHeight(final View view, float start, float end) { final ValueAnimator animator = ValueAnimator.ofFloat(start, end); final ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w ww . j a v a2s . c om public void onAnimationUpdate(ValueAnimator valueAnimator) { float value = (Float) animator.getAnimatedValue(); layoutParams.height = (int) value; view.setLayoutParams(layoutParams); Log.i(TAG, "onAnimationUpdate: value=" + value); } }); animator.setDuration(500); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); }
From source file:Main.java
/** * Animates a view to the new specified dimensions. * @param view The view to change the dimensions of. * @param newWidth The new width of the view. * @param newHeight The new height of the view. *//*from w ww.j a v a 2s. c o m*/ public static void changeDimensions(final View view, final int newWidth, final int newHeight) { ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); final int oldWidth = view.getWidth(); final int oldHeight = view.getHeight(); final int deltaWidth = newWidth - oldWidth; final int deltaHeight = newHeight - oldHeight; animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); view.getLayoutParams().width = (int) (value * deltaWidth + oldWidth); view.getLayoutParams().height = (int) (value * deltaHeight + oldHeight); view.requestLayout(); } }); animator.start(); }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static void animateBackgroundDim(final ViewGroup backgroundLayout, boolean reverse) { int transColor = reverse ? R.color.black_trans : android.R.color.transparent; int blackTransColor = reverse ? android.R.color.transparent : R.color.black_trans; ValueAnimator anim = new ValueAnimator(); anim.setIntValues(transColor, blackTransColor); anim.setEvaluator(new ArgbEvaluator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w .j a v a 2 s. c om public void onAnimationUpdate(ValueAnimator valueAnimator) { backgroundLayout.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.setDuration(SLIDE_ANIMATION_DURATION); anim.start(); }
From source file:com.musenkishi.wally.util.PaletteLoader.java
private static void applyColorToView(final PaletteTarget target, int color, boolean fromCache) { if (target.getView() instanceof TextView) { applyColorToView((TextView) target.getView(), color, fromCache); return;// w ww . j a va 2s . c o m } if (fromCache) { if (target.getView() instanceof ImageView && target.shouldMaskDrawable()) { ((ImageView) target.getView()).getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } else { target.getView().setBackgroundColor(color); } } else { if (target.getView() instanceof ImageView && target.shouldMaskDrawable()) { Integer colorFrom; ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ((ImageView) target.getView()).getDrawable().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } }; ValueAnimator.AnimatorUpdateListener animatorUpdateListener; PaletteTag paletteTag = (PaletteTag) target.getView().getTag(); animatorUpdateListener = imageAnimatorUpdateListener; colorFrom = paletteTag.getColor(); target.getView().setTag(new PaletteTag(paletteTag.getId(), color)); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(animatorUpdateListener); colorAnimation.setDuration(300); colorAnimation.start(); } else { Drawable preDrawable; if (target.getView().getBackground() == null) { preDrawable = new ColorDrawable(Color.TRANSPARENT); } else { preDrawable = target.getView().getBackground(); } TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[] { preDrawable, new ColorDrawable(color) }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { target.getView().setBackground(transitionDrawable); } else { target.getView().setBackgroundDrawable(transitionDrawable); } transitionDrawable.startTransition(300); } } }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final TextView textView, int color, boolean fromCache) { if (fromCache) { textView.setTextColor(color);// w w w . ja v a 2s.c o m } else { Integer colorFrom = textView.getCurrentTextColor(); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); } }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final CardView cardView, int color, boolean fromCache) { if (fromCache) { cardView.setCardBackgroundColor(color); } else {/*from w ww.jav a 2 s . c o m*/ Integer colorFrom = Color.parseColor("#FFFAFAFA"); //Default light CardView color. Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { cardView.setCardBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setDuration(300); colorAnimation.start(); } }
From source file:com.harlan.jxust.ui.view.bottombar.MiscUtils.java
/** * A method for animating width for the tabs. * @param tab tab to animate.//ww w.j a va2 s .c o m * @param start starting width. * @param end final width after animation. */ protected static void resizeTab(final View tab, float start, float end) { ValueAnimator animator = ValueAnimator.ofFloat(start, end); animator.setDuration(150); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { ViewGroup.LayoutParams params = tab.getLayoutParams(); if (params == null) return; params.width = Math.round((float) animator.getAnimatedValue()); tab.setLayoutParams(params); } }); animator.start(); }