本文整理汇总了Java中android.animation.ValueAnimator.start方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.start方法的具体用法?Java ValueAnimator.start怎么用?Java ValueAnimator.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: onFinish
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public int onFinish(@NonNull RefreshLayout layout, boolean success) {
mShowOuter = false;
mShowBoll = false;
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mFinishRatio = (float) animation.getAnimatedValue();
BezierCircleHeader.this.invalidate();
}
});
animator.setInterpolator(new AccelerateInterpolator());
animator.setDuration(DURATION_FINISH);
animator.start();
return DURATION_FINISH;
}
示例3: startColorGradientAnim
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void startColorGradientAnim(int duration, final View view, @Nullable Animator.AnimatorListener listener, int... values) {
final ValueAnimator anim = ObjectAnimator.ofArgb(values);
anim.setDuration(duration);
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int va = (int) animation.getAnimatedValue();
view.setBackgroundColor(va);
}
});
if (listener != null) {
anim.addListener(listener);
}
anim.start();
}
示例4: setUpAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override public void setUpAnimation() {
for (int i = 0; i < circlesSize; i++) {
final int index = i;
ValueAnimator fadeAnimator = ValueAnimator.ofInt(126, 255, 126);
fadeAnimator.setRepeatCount(ValueAnimator.INFINITE);
fadeAnimator.setDuration(1000);
fadeAnimator.setStartDelay(index * 120);
fadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
circles[index].setAlpha((int)animation.getAnimatedValue());
if (invalidateListener != null) {
invalidateListener.reDraw();
}
}
});
fadeAnimator.start();
}
}
示例5: animateShadeClose
import android.animation.ValueAnimator; //导入方法依赖的package包/类
void animateShadeClose() {
this.phone.performHapticFeedback(3, 2);
updateText(this.explanation, R.string.oob_pullout_shade_all_the_way, 0, null);
final float dimIncrement = this.dimValue / ((float) this.shadeHeight);
float currentHeight = (float) this.shade.getHeight();
ValueAnimator va = ValueAnimator.ofInt(new int[]{(int) currentHeight, 0});
va.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Integer height = (Integer) animation.getAnimatedValue();
LayoutParams layoutParams = OOBTutorialActivity.this.shade.getLayoutParams();
layoutParams.height = height.intValue();
OOBTutorialActivity.this.shade.setLayoutParams(layoutParams);
OOBTutorialActivity.this.dim.setAlpha(height.floatValue() * dimIncrement);
OOBTutorialActivity.this.shade.requestLayout();
}
});
va.start();
}
示例6: animateToolbar
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void animateToolbar(final float toY) {
float layoutTranslationY = ViewCompat.getTranslationY(mInterceptionLayout);
if (layoutTranslationY != toY) {
ValueAnimator animator = ValueAnimator.ofFloat(ViewCompat.getTranslationY(mInterceptionLayout), toY).setDuration(200);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float translationY = (float) animation.getAnimatedValue();
View tView = adjustmentToolBarView();
ViewCompat.setTranslationY(mInterceptionLayout, translationY);
ViewCompat.setTranslationY(tView, translationY);
if (translationY < 0) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
lp.height = (int) (-translationY + getScreenHeight());
mInterceptionLayout.requestLayout();
}
}
});
animator.start();
}
}
示例7: createAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
long[] delays=new long[]{500,250,0,250,500};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
scaleAnim.setDuration(900);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.start();
animators.add(scaleAnim);
}
return animators;
}
示例8: startAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void startAnimation() {
ValueAnimator valueAnimator = ValueAnimator.ofInt(0,mBitmapDST.getWidth());
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setDuration(5000);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
dx = (int) animation.getAnimatedValue();
postInvalidate();
}
});
valueAnimator.start();
}
示例9: showHeight
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public static void showHeight(final View view,float start,float end){
final ValueAnimator animator=ValueAnimator.ofFloat(start,end);
final ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = (Float) animator.getAnimatedValue();
layoutParams.height=(int) value;
view.setLayoutParams(layoutParams);
Log.i(TAG, "onAnimationUpdate: value="+value);
}
});
animator.setDuration(500);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
示例10: slowSmoothScrollTo
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/** slower than smoothScrollTo */
private void slowSmoothScrollTo(final ScrollView parentScrollView, int scrollY, int autoScrollAnimationTime) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ValueAnimator realSmoothScrollAnimation =
ValueAnimator.ofInt(parentScrollView.getScrollY(), scrollY);
realSmoothScrollAnimation.setDuration(autoScrollAnimationTime);
realSmoothScrollAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int scrollTo = (Integer) animation.getAnimatedValue();
parentScrollView.scrollTo(0, scrollTo);
}
});
realSmoothScrollAnimation.start();
} else {
parentScrollView.smoothScrollTo(0, scrollY);
}
}
示例11: onClick
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@OnClick(R.id.grow)
public void onClick() {
ValueAnimator valueAnimator=new ValueAnimator().ofObject(new StudentEvaluator(),new Student(0,40),new Student(100,300));
valueAnimator.setDuration(5000);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Student student = (Student) animation.getAnimatedValue();
info.setText("学生年龄:"+student.getAge()+"岁,学生身高:"+student.getHeight()+"cm");
}
});
valueAnimator.start();
}
示例12: startRotate
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void startRotate() {
ValueAnimator animator = ValueAnimator.ofInt(0,360);
animator.setDuration(2000);
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mDegrees = (int) animation.getAnimatedValue();
invalidate();
}
});
animator.start();
}
示例13: startSuccessSymbolAnim
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 开始加载成功动画
*/
private void startSuccessSymbolAnim() {
currentPath.reset();
pathMeasure.setPath(successSymbolPath, false);
pathMeasure.getPosTan(0, mCurrentPosition, null);
currentPath.moveTo(mCurrentPosition[0], mCurrentPosition[1]);
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, pathMeasure.getLength());
valueAnimator.setDuration(500);
// 减速插值器
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (isLoading)
return;
float value = (Float) animation.getAnimatedValue();
// 获取当前点坐标封装到mCurrentPosition
float[] tmp = mCurrentPosition;
pathMeasure.getPosTan(value, mCurrentPosition, null);
currentPath.quadTo(tmp[0], tmp[1], mCurrentPosition[0], mCurrentPosition[1]);
invalidateCallback.redraw();
}
});
valueAnimator.start();
}
示例14: imageColorChange
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public static void imageColorChange(final ImageView image, int fromColor, int toColor) {
ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
image.setColorFilter((Integer) animator.getAnimatedValue());
}
});
imageColorChangeAnimation.setDuration(150);
imageColorChangeAnimation.start();
}
示例15: animateInHorizontal
import android.animation.ValueAnimator; //导入方法依赖的package包/类
void animateInHorizontal() {
ValueAnimator animator = ValueAnimator.ofFloat(0.0f, getHeight());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
pathIn = new Path();
pathIn.moveTo(0.0f, (Float) valueAnimator.getAnimatedValue() - paint.getFontMetrics().bottom);
pathIn.lineTo(getWidth(), (Float) valueAnimator.getAnimatedValue() - paint.getFontMetrics().bottom);
rotatable.setPathIn(pathIn);
}
});
animator.setInterpolator(rotatable.getInterpolator());
animator.setDuration(rotatable.getAnimationDuration());
animator.start();
}