本文整理匯總了Java中android.animation.ValueAnimator.setIntValues方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueAnimator.setIntValues方法的具體用法?Java ValueAnimator.setIntValues怎麽用?Java ValueAnimator.setIntValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.setIntValues方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startAnim
import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
* 給背景設置一個動畫
*
* @param endProgress 動畫的結束進度
* @param endCallback 動畫結束時觸發
*/
private void startAnim(float endProgress, final Runnable endCallback) {
// 獲取一個最終的顏色
int finalColor = Resource.Color.WHITE; // UiCompat.getColor(getResources(), R.color.white);
// 運算當前進度的顏色
ArgbEvaluator evaluator = new ArgbEvaluator();
int endColor = (int) evaluator.evaluate(endProgress, mBgDrawable.getColor(), finalColor);
// 構建一個屬性動畫
ValueAnimator valueAnimator = ObjectAnimator.ofObject(this, property, evaluator, endColor);
valueAnimator.setDuration(1500); // 時間
valueAnimator.setIntValues(mBgDrawable.getColor(), endColor); // 開始結束值
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
// 結束時觸發
endCallback.run();
}
});
valueAnimator.start();
}
示例2: SLTouchListener
import android.animation.ValueAnimator; //導入方法依賴的package包/類
public SLTouchListener(SphereLayout sphereLayout) {
mSphereLayout = sphereLayout;
mTouchSlop = ViewConfiguration.get(mSphereLayout.getContext()).getScaledTouchSlop();
mInterpolator = new SpringInterpolator();
mState = new RotateState();
mRotateAnimator = new ValueAnimator();
mRotateAnimator.setInterpolator(mInterpolator);
mRotateAnimator.setIntValues(MAX_ROTATE_DEGREE, 0);
mRotateAnimator.setDuration(DURATION);
mRotateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mState.rotateDegree = (Integer) animation.getAnimatedValue();
mSphereLayout.rotate(mState.direction, mState.rotateDegree);
}
});
mFixAnimator = new ValueAnimator();
mFixAnimator.setInterpolator(new DecelerateInterpolator());
}
示例3: 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;
}
示例4: 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();
}
示例5: LineFadeIndicator
import android.animation.ValueAnimator; //導入方法依賴的package包/類
public LineFadeIndicator(DachshundTabLayout dachshundTabLayout) {
this.dachshundTabLayout = dachshundTabLayout;
valueAnimator = new ValueAnimator();
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setDuration(DEFAULT_DURATION);
valueAnimator.addUpdateListener(this);
valueAnimator.setIntValues(0,255);
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
rectF = new RectF();
startXLeft = (int) dachshundTabLayout.getChildXLeft(dachshundTabLayout.getCurrentPosition());
startXRight = (int) dachshundTabLayout.getChildXRight(dachshundTabLayout.getCurrentPosition());
edgeRadius = -1;
}
示例6: createValueAnimator
import android.animation.ValueAnimator; //導入方法依賴的package包/類
public static ValueAnimator createValueAnimator(AnimatedDrawable2 animatedDrawable) {
int loopCount = animatedDrawable.getLoopCount();
ValueAnimator animator = new ValueAnimator();
animator.setIntValues(0, (int) animatedDrawable.getLoopDurationMs());
animator.setDuration(animatedDrawable.getLoopDurationMs());
animator.setRepeatCount(
loopCount != AnimationInformation.LOOP_COUNT_INFINITE ? loopCount : ValueAnimator.INFINITE);
animator.setRepeatMode(ValueAnimator.RESTART);
// Use a linear interpolator
animator.setInterpolator(null);
ValueAnimator.AnimatorUpdateListener animatorUpdateListener =
createAnimatorUpdateListener(animatedDrawable);
animator.addUpdateListener(animatorUpdateListener);
return animator;
}
示例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: 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();
}
示例9: showProgress
import android.animation.ValueAnimator; //導入方法依賴的package包/類
public void showProgress(int duration) {
if (isProgressShowing) {
return;
}
isProgressShowing = true;
status = Status.SHOWING;
final int bw = button.getMeasuredWidth();
buttonWidth = bw;
buttonText = button.getText().toString();
buttonBg = button.getBackground();
button.setEnabled(false);
button.setBackgroundResource(bgResId);
final int pw = progress.getMeasuredWidth();
ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
valueAnimator.setDuration(duration);
valueAnimator.setIntValues(bw, pw);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (status != Status.SHOWING) {
return;
}
int value = (int) animation.getAnimatedValue();
button.getLayoutParams().width = value;
button.requestLayout();
if (value == pw) {
progress.animate().alpha(1f).start();
status = Status.SHOWED;
}
}
});
//button.setText(null);
valueAnimator.start();
}
示例10: PointFadeIndicator
import android.animation.ValueAnimator; //導入方法依賴的package包/類
public PointFadeIndicator(DachshundTabLayout dachshundTabLayout) {
this.dachshundTabLayout = dachshundTabLayout;
valueAnimator = new ValueAnimator();
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setDuration(DEFAULT_DURATION);
valueAnimator.addUpdateListener(this);
valueAnimator.setIntValues(0,255);
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
startX = (int) dachshundTabLayout.getChildXCenter(dachshundTabLayout.getCurrentPosition());
}
示例11: initBlinkingAnimators
import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void initBlinkingAnimators(final int index, ValueAnimator opacityAnimator) {
opacityAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
opacityAnimator.setIntValues(mInitialOpacity, mTargetOpacity, mInitialOpacity);
opacityAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int opacity = (int) animation.getAnimatedValue();
mAlphaOpacityList.set(index, opacity);
}
});
}
示例12: initShinyAnimators
import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void initShinyAnimators(final int index, ValueAnimator opacityAnimator) {
opacityAnimator.setRepeatMode(ValueAnimator.REVERSE);
final float opacityDecelerateFactor = 1.f + 0.8f * (index + 1);
opacityAnimator.setInterpolator(new DecelerateInterpolator(opacityDecelerateFactor));
opacityAnimator.setIntValues(255, 50, 255);
opacityAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int opacity = (int) animation.getAnimatedValue();
mAlphaOpacityList.set(index, opacity);
}
});
}
示例13: initAuraAnimators
import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void initAuraAnimators(final int index, ValueAnimator opacityAnimator) {
opacityAnimator.setRepeatMode(ValueAnimator.REVERSE);
final float opacityDecelerateFactor = 1.f + 0.8f * (index + 1);
opacityAnimator.setInterpolator(new AnticipateInterpolator(opacityDecelerateFactor));
opacityAnimator.setIntValues(255, 50, 255, 50);
opacityAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int opacity = (int) animation.getAnimatedValue();
mAlphaOpacityList.set(index, opacity);
}
});
}