当前位置: 首页>>代码示例>>Java>>正文


Java ValueAnimator.setEvaluator方法代码示例

本文整理汇总了Java中android.animation.ValueAnimator.setEvaluator方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.setEvaluator方法的具体用法?Java ValueAnimator.setEvaluator怎么用?Java ValueAnimator.setEvaluator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.animation.ValueAnimator的用法示例。


在下文中一共展示了ValueAnimator.setEvaluator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setColor

import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:MaterialViewPagerAnimator.java

示例2: createAppearBackgroundAnimator

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private Animator createAppearBackgroundAnimator() {
    int startColor = ResourcesCompat.getColor(getResources(),
            BACGROUND_TRANSPARENT_COLOR_RES,
            getContext().getTheme()
    );
    int finColor = ResourcesCompat.getColor(getResources(),
            BACKGROUND_COLOR_RES,
            getContext().getTheme()
    );
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, finColor);
    anim.setEvaluator(ArgbEvaluator.getInstance());
    anim.setStartDelay(ANIMATION_DURATION / 2);
    anim.setDuration(ANIMATION_DURATION / 2);
    anim.addUpdateListener(animation -> {
        int color = (int) animation.getAnimatedValue();
        setBackgroundColor(color);
    });
    return anim;
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:21,代码来源:ExpandedView.java

示例3: ease

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void ease(final View view) {
    Easing easing = new Easing(1000);
    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(700);
    animatorSet.start();
}
 
开发者ID:ahmadnurhidayat,项目名称:Sign-Up,代码行数:21,代码来源:SignUp.java

示例4: ease2

import android.animation.ValueAnimator; //导入方法依赖的package包/类
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();
}
 
开发者ID:ahmadnurhidayat,项目名称:Sign-Up,代码行数:21,代码来源:SignUp.java

示例5: recolorBackground

import android.animation.ValueAnimator; //导入方法依赖的package包/类
public static void recolorBackground(final View view,
                                     final int startColor,
                                     final int endColor,
                                     final int duration) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, endColor);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setBackgroundColor((Integer) animation.getAnimatedValue());
        }
    });
    anim.setDuration(duration);
    anim.start();
}
 
开发者ID:interactiveservices,项目名称:utils-android,代码行数:17,代码来源:AnimUtils.java

示例6: setCodeSegment

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void setCodeSegment(final TextView codeView, String segment) {
  if (Build.VERSION.SDK_INT >= 11) {
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setObjectValues(0, Integer.parseInt(segment));

    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
      @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
      @Override
      public void onAnimationUpdate(ValueAnimator animation) {
        int value = (int) animation.getAnimatedValue();
        codeView.setText(String.format("%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();
  } else {
    codeView.setText(segment);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:27,代码来源:VerifyIdentityActivity.java

示例7: createColorAnimation

import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
 * this method replace for ValueAnimator.ofArgb() support below sdk 6.0
 *
 * @param values
 * @return
 */
private ValueAnimator createColorAnimation(int... values) {
    ValueAnimator colorAnimation = new ValueAnimator();
    colorAnimation.setIntValues(values);
    colorAnimation.setEvaluator(new ArgbEvaluator());
    colorAnimation.setDuration(ANIMATION_DURATION);
    return colorAnimation;
}
 
开发者ID:arjinmc,项目名称:AndroidButtonLib,代码行数:14,代码来源:SubmitButton.java

示例8: newArgbValueAnimator

import android.animation.ValueAnimator; //导入方法依赖的package包/类
@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;
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:8,代码来源:NumberPadTimePickerBottomSheetComponent.java

示例9: animateColors

import android.animation.ValueAnimator; //导入方法依赖的package包/类
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();
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:15,代码来源:BottomBarTab.java


注:本文中的android.animation.ValueAnimator.setEvaluator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。