Java Code Examples for android.animation.ValueAnimator#setEvaluator()
The following examples show how to use
android.animation.ValueAnimator#setEvaluator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VerifyIdentityActivity.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void setCodeSegment(final TextView codeView, String segment) { ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.setObjectValues(0, Integer.parseInt(segment)); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (int) animation.getAnimatedValue(); codeView.setText(String.format(Locale.getDefault(), "%05d", value)); } }); valueAnimator.setEvaluator(new TypeEvaluator<Integer>() { public Integer evaluate(float fraction, Integer startValue, Integer endValue) { return Math.round(startValue + (endValue - startValue) * fraction); } }); valueAnimator.setDuration(1000); valueAnimator.start(); }
Example 2
Source File: TextViewLinkActivity.java From zone-sdk with MIT License | 6 votes |
public ForegroundColorSpanAni(View view) { this.view = view; ValueAnimator animator = ValueAnimator.ofInt(Color.RED, Color.BLUE); animator.setEvaluator(new ArgbEvaluator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { color = (int) animation.getAnimatedValue(); view.invalidate(); } }); animator.setRepeatMode(ValueAnimator.REVERSE); animator.setRepeatCount(-1); animator.start(); }
Example 3
Source File: MaterialViewPagerAnimator.java From MaterialViewPager with Apache License 2.0 | 6 votes |
/** * Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip * With a color transition animation * * @param color the final color * @param duration the transition color animation duration */ void setColor(int color, int duration) { final ValueAnimator colorAnim = ObjectAnimator.ofInt(mHeader.headerBackground, "backgroundColor", settings.color, color); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setDuration(duration); colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { final int animatedValue = (Integer) animation.getAnimatedValue(); int colorAlpha = colorWithAlpha(animatedValue, lastPercent); mHeader.headerBackground.setBackgroundColor(colorAlpha); mHeader.statusBackground.setBackgroundColor(colorAlpha); mHeader.toolbar.setBackgroundColor(colorAlpha); mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha); mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha); //set the new color as MaterialViewPager's color settings.color = animatedValue; } }); colorAnim.start(); }
Example 4
Source File: SignUp.java From Sign-Up with GNU General Public License v3.0 | 6 votes |
private void ease2(final View view) { Easing easing = new Easing(1200); AnimatorSet animatorSet = new AnimatorSet(); float fromY = 600; float toY = view.getTop(); ValueAnimator valueAnimatorY = ValueAnimator.ofFloat(fromY,toY); valueAnimatorY.setEvaluator(easing); valueAnimatorY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { view.setTranslationY((float) animation.getAnimatedValue()); } }); animatorSet.playTogether(valueAnimatorY); animatorSet.setDuration(1100); animatorSet.start(); }
Example 5
Source File: MainActivity.java From APKMirror with GNU General Public License v2.0 | 6 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private void changeUIColor(Integer color) { ValueAnimator anim = ValueAnimator.ofArgb(previsionThemeColor, color); anim.setEvaluator(new ArgbEvaluator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { progressBar.getProgressDrawable().setColorFilter(new LightingColorFilter(0xFF000000, (Integer) valueAnimator.getAnimatedValue())); setSystemBarColor((Integer) valueAnimator.getAnimatedValue()); navigation.setActiveTabColor((Integer) valueAnimator.getAnimatedValue()); fabSearch.setBackgroundTintList(ColorStateList.valueOf((Integer) valueAnimator.getAnimatedValue())); } }); anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)); anim.start(); refreshLayout.setColorSchemeColors(color, color, color); }
Example 6
Source File: MainActivity.java From Android with MIT License | 5 votes |
private void selectRightAnswer(Button btn) { int colorStart=btn.getSolidColor(); int colorEnd=getResources().getColor(R.color.colorPrimary); ValueAnimator valueAnimator = ObjectAnimator.ofInt(btn,"backgroundColor",colorStart,colorEnd); valueAnimator.setDuration(300); valueAnimator.setEvaluator(new ArgbEvaluator()); btn.setTextColor(getResources().getColor(R.color.color_white)); valueAnimator.setRepeatCount(0); valueAnimator.start(); hideButtons(); }
Example 7
Source File: BasePermissionActivity.java From PermissionHelper with Apache License 2.0 | 5 votes |
private void animateColorChange(final View view, final int color) { ValueAnimator animator = new ValueAnimator(); animator.setIntValues(((ColorDrawable) view.getBackground()).getColor(), color); animator.setEvaluator(new ArgbEvaluator()); animator.setDuration(600); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { view.setBackgroundColor((Integer) animation.getAnimatedValue()); onStatusBarColorChange((Integer) animation.getAnimatedValue()); } }); animator.start(); }
Example 8
Source File: PathAnimatorInflater.java From ElasticProgressBar with Apache License 2.0 | 5 votes |
/** * @param anim The animator, must not be null * @param arrayAnimator Incoming typed array for Animator's attributes. * @param arrayObjectAnimator Incoming typed array for Object Animator's * attributes. */ private static void parseAnimatorFromTypeArray(ValueAnimator anim, TypedArray arrayAnimator, TypedArray arrayObjectAnimator) { long duration = arrayAnimator.getInt(R.styleable.Animator_android_duration, 300); long startDelay = arrayAnimator.getInt(R.styleable.Animator_android_startOffset, 0); int valueType = arrayAnimator.getInt(R.styleable.Animator_vc_valueType, 0); TypeEvaluator evaluator = null; // Must be a path animator by the time I reach here if (valueType == VALUE_TYPE_PATH) { evaluator = setupAnimatorForPath(anim, arrayAnimator); } else { throw new IllegalArgumentException("target is not a pathType target"); } anim.setDuration(duration); anim.setStartDelay(startDelay); if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatCount)) { anim.setRepeatCount( arrayAnimator.getInt(R.styleable.Animator_android_repeatCount, 0)); } if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatMode)) { anim.setRepeatMode( arrayAnimator.getInt(R.styleable.Animator_android_repeatMode, ValueAnimator.RESTART)); } if (evaluator != null) { anim.setEvaluator(evaluator); } if (arrayObjectAnimator != null) { setupObjectAnimator(anim, arrayObjectAnimator); } }
Example 9
Source File: PulsateAnimation.java From Kore with Apache License 2.0 | 5 votes |
private ValueAnimator createValueAnimator(int startColor, int endColor) { ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.setDuration(1000); valueAnimator.setIntValues(startColor, endColor); valueAnimator.setEvaluator(new ArgbEvaluator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { int color = (int) animator.getAnimatedValue(); view.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN); } }); return valueAnimator; }
Example 10
Source File: PropertyAnimActivity.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
public void testColor(View v) { ValueAnimator colorAnim = ObjectAnimator.ofInt(v, "backgroundColor", /*Red*/0xFFFF8080, /*Blue*/0xFF8080FF); colorAnim.setDuration(C.Int.ANIM_DURATION * 3); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setRepeatCount(ValueAnimator.INFINITE); colorAnim.setRepeatMode(ValueAnimator.REVERSE); colorAnim.start(); }
Example 11
Source File: NumberPadTimePickerBottomSheetComponent.java From BottomSheetPickers with Apache License 2.0 | 5 votes |
@NonNull private static ValueAnimator newArgbValueAnimator(int[] colors) { // Equivalent to ValueAnimator.ofArgb() which is only for API 21+. ValueAnimator animator = ValueAnimator.ofInt(colors); animator.setEvaluator(new ArgbEvaluator()); return animator; }
Example 12
Source File: BottomBarTab.java From BottomBar with Apache License 2.0 | 5 votes |
private void animateColors(int previousColor, int color) { ValueAnimator anim = new ValueAnimator(); anim.setIntValues(previousColor, color); anim.setEvaluator(new ArgbEvaluator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { setColors((Integer) valueAnimator.getAnimatedValue()); } }); anim.setDuration(150); anim.start(); }
Example 13
Source File: NumberPadTimePickerBottomSheetComponent.java From NumberPadTimePicker with Apache License 2.0 | 5 votes |
@NonNull private static ValueAnimator newArgbValueAnimator(int[] colors) { // Equivalent to ValueAnimator.ofArgb() which is only for API 21+. ValueAnimator animator = ValueAnimator.ofInt(colors); animator.setEvaluator(new ArgbEvaluator()); return animator; }
Example 14
Source File: Glider.java From AnimationEasingFunctions with MIT License | 5 votes |
public static ValueAnimator glide(Skill skill, float duration, ValueAnimator animator, BaseEasingMethod.EasingListener... listeners) { BaseEasingMethod t = skill.getMethod(duration); if (listeners != null) t.addEasingListeners(listeners); animator.setEvaluator(t); return animator; }
Example 15
Source File: MoreMenuHelper.java From Android_UE with Apache License 2.0 | 5 votes |
/** * 旋转菜单按钮 */ private void rotationActionMenu(int from, int to) { ValueAnimator fadeAnim = ObjectAnimator.ofFloat(fabCloseMoreMenu, "rotation", from, to); fadeAnim.setDuration(300); KickBackAnimator kickAnimator = new KickBackAnimator(); kickAnimator.setDuration(150); fadeAnim.setEvaluator(kickAnimator); fadeAnim.start(); }
Example 16
Source File: AnimationUtils.java From SearchPreference with MIT License | 5 votes |
private static void startColorAnimation(final View view, final int startColor, final int endColor, int duration) { ValueAnimator anim = new ValueAnimator(); anim.setIntValues(startColor, endColor); anim.setEvaluator(new ArgbEvaluator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { view.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.setDuration(duration); anim.start(); }
Example 17
Source File: ColorAnimation.java From XDroidAnimation with Apache License 2.0 | 5 votes |
@Override public AnimatorSet createAnimatorSet() { ValueAnimator colorAnim = ObjectAnimator.ofInt(targetView, propertiesName, values); colorAnim.setDuration(3000); colorAnim.setEvaluator(new ArgbEvaluator()); AnimatorSet colorSet = new AnimatorSet(); colorSet.play(colorAnim); if (listener != null) { colorSet.addListener(listener); } return colorSet; }
Example 18
Source File: AnimationUtils.java From adamant-android with GNU General Public License v3.0 | 5 votes |
private static void startBackgroundColorAnimation(final View view, int startColor, int endColor, int duration) { ValueAnimator anim = new ValueAnimator(); anim.setIntValues(startColor, endColor); anim.setEvaluator(new ArgbEvaluator()); anim.setDuration(duration); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { view.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.start(); }
Example 19
Source File: AnimUtil.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static Animator animNumSwitch(int i1, int j1, TextView textview) { int k1 = j1 - i1; String s = String.valueOf(Math.abs(k1)); int ai[] = new int[s.length()]; for (int l1 = 0; l1 < s.length(); l1++) { ai[l1] = -48 + s.charAt(-1 + (s.length() - l1)); } ArrayList arraylist = new ArrayList(); arraylist.add(formatNumStyle(i1)); int i2 = 0; int j2 = 1; do { if (i2 >= ai.length) { break; } int i3 = Integer.valueOf(ai[i2]).intValue(); int j3 = 0; while (j3 < i3) { if (k1 > 0) { i1 += j2; } else if (k1 < 0) { i1 -= j2; } arraylist.add(formatNumStyle(i1)); j3++; } j2 *= 10; i2++; } while (true); arraylist.add(formatNumStyle(j1)); Keyframe akeyframe[] = new Keyframe[1 + arraylist.size()]; int k2 = 0; while (k2 <= arraylist.size()) { float f1 = (1.0F / (float)arraylist.size()) * (float)k2; int l2; if (k2 == 0) { l2 = 0; } else { l2 = k2 - 1; } akeyframe[k2] = Keyframe.ofObject(f1, arraylist.get(l2)); k2++; } ValueAnimator valueanimator = ValueAnimator.ofPropertyValuesHolder(new PropertyValuesHolder[] { PropertyValuesHolder.ofKeyframe("Text", akeyframe) }); valueanimator.setEvaluator(new g()); valueanimator.addUpdateListener(new h(textview)); valueanimator.setDuration(20 * akeyframe.length); return valueanimator; }
Example 20
Source File: AnimUtil.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static Animator animNumSwitch1(int i1, int j1, TextView textview) { String s = String.valueOf(i1); int ai[] = new int[s.length()]; for (int k1 = 0; k1 < s.length(); k1++) { ai[-1 + (s.length() - k1)] = -48 + s.charAt(k1); Debug.i("Chart.AnimUtil", (new StringBuilder()).append("Num : ").append(ai[-1 + (s.length() - k1)]).toString()); } String s1 = String.valueOf(j1); int ai1[] = new int[s1.length()]; for (int l1 = 0; l1 < s1.length(); l1++) { ai1[-1 + (s1.length() - l1)] = -48 + s1.charAt(l1); Debug.i("Chart.AnimUtil", (new StringBuilder()).append("Num : ").append(ai1[-1 + (s1.length() - l1)]).toString()); } ArrayList arraylist = new ArrayList(); for (int i2 = -1 + ai1.length; i2 >= 0; i2--) { int k2 = ai1[i2]; int l2; if (ai.length > i2) { l2 = ai[i2]; } else { l2 = 0; } if (k2 > l2) { for (int j3 = 0; j3 < 1 + (k2 - l2); j3++) { arraylist.add(a(s, s1, i2, l2 + j3)); } continue; } if (k2 < l2) { for (int i3 = 0; i3 < 1 + (l2 - k2); i3++) { arraylist.add(a(s, s1, i2, l2 - i3)); } } else { arraylist.add(a(s, s1, i2, l2)); } } Keyframe akeyframe[] = new Keyframe[1 + arraylist.size()]; Iterator iterator = arraylist.iterator(); int j2 = 0; while (iterator.hasNext()) { String s2 = (String)iterator.next(); j2++; akeyframe[j2] = Keyframe.ofObject((1.0F / (float)arraylist.size()) * (float)j2, s2); } akeyframe[0] = akeyframe[1]; ValueAnimator valueanimator = ValueAnimator.ofPropertyValuesHolder(new PropertyValuesHolder[] { PropertyValuesHolder.ofKeyframe("Text", akeyframe) }); valueanimator.setEvaluator(new i()); valueanimator.addUpdateListener(new j(textview)); valueanimator.setDuration(20L); return valueanimator; }