本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}