List of usage examples for android.animation ValueAnimator setDuration
@Override public ValueAnimator setDuration(long duration)
From source file:Main.java
/** * Update text color with animation//from ww w.j a v a 2s. c o 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
public static Animator createNoAnimationAnimator(View view) { ValueAnimator anim = ValueAnimator.ofInt(0, 1); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(1); return anim;//from w w w . j a v a 2 s. c om }
From source file:Main.java
@SuppressWarnings("deprecation") public static void clipDrawable(final View image, Drawable drawable, boolean isActivated) { if (drawable == null) { return;/*from w ww . j ava 2s.c om*/ } 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); } } }
From source file:Main.java
public static void changeTextColor(final TextView textView, int fromColor, int toColor) { ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); changeTextColorAnimation.setDuration(150); changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w . j a v a 2 s . c o m*/ public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); changeTextColorAnimation.start(); }
From source file:Main.java
static void changeTextColor(final TextView textView, int fromColor, int toColor) { ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); changeTextColorAnimation.setDuration(150); changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// www. jav a2s . c o m public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); changeTextColorAnimation.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./*from w ww . ja v a2 s .com*/ * @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(); }
From source file:Main.java
static void changeImageColorFilter(final ImageView image, int fromColor, int toColor) { ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w. j a va 2 s . co m*/ public void onAnimationUpdate(ValueAnimator animator) { image.setColorFilter((Integer) animator.getAnimatedValue()); } }); imageColorChangeAnimation.setDuration(150); imageColorChangeAnimation.start(); }
From source file:Main.java
public static void backgroundColorChange(final View view, int fromColor, int toColor) { ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w w w. jav a 2 s . co m*/ public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); imageColorChangeAnimation.setDuration(150); imageColorChangeAnimation.start(); }
From source file:Main.java
static void changeViewBackgroundColor(final View view, int fromColor, int toColor) { ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from www . jav a 2 s. co m*/ public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); imageColorChangeAnimation.setDuration(150); imageColorChangeAnimation.start(); }
From source file:com.pdftron.pdf.utils.ViewerUtils.java
/** * Creates an Animator object that varies the alpha property of the view. The * interpolation used is linear./* w w w . ja v a 2 s. c om*/ * * @param view the view to be animated * @param listener the listener to be used by this Animator * * @return a new Animator object that will change the "alpha" property * of the view. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static Animator createAlphaAnimator(View view, Animator.AnimatorListener listener) { if (view == null) { return null; } // We animate only the opacity of the view. ValueAnimator fader = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f, 0.4f, 1.0f, 0.0f); fader.setDuration(1500); fader.setEvaluator(new FloatEvaluator()); if (listener != null) { fader.addListener(listener); } return fader; }