Java Code Examples for android.animation.ValueAnimator#start()
The following examples show how to use
android.animation.ValueAnimator#start() .
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: ScrollScaleAnimator.java From YCDialog with Apache License 2.0 | 6 votes |
@Override public void animateDismiss() { ValueAnimator animator = ValueAnimator.ofFloat(0, 1); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float fraction = animation.getAnimatedFraction(); targetView.setAlpha(floatEvaluator.evaluate(fraction, 1f, startAlpha)); targetView.scrollTo(intEvaluator.evaluate(fraction, 0, startScrollX), intEvaluator.evaluate(fraction, 0, startScrollY)); float scale = floatEvaluator.evaluate(fraction, 1f, startScale); targetView.setScaleX(scale); if(!isOnlyScaleX)targetView.setScaleY(scale); if(targetView.getBackground()!=null)targetView.getBackground().setAlpha((int) (fraction*255)); } }); animator.setDuration(animationDuration) .setInterpolator(new FastOutSlowInInterpolator()); animator.start(); }
Example 2
Source File: PhoneWave.java From mkloader with Apache License 2.0 | 6 votes |
@Override public void setUpAnimation() { for (int i = 0; i < numberOfArc; i++) { final int index = i; ValueAnimator fadeAnimator = ValueAnimator.ofInt(126, 255, 126); fadeAnimator.setRepeatCount(ValueAnimator.INFINITE); fadeAnimator.setDuration(1000); fadeAnimator.setStartDelay(i * 120); fadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { arcs[index].setAlpha((int)animation.getAnimatedValue()); if (invalidateListener != null) { invalidateListener.reDraw(); } } }); fadeAnimator.start(); } }
Example 3
Source File: FloatingView.java From text_converter with GNU General Public License v3.0 | 6 votes |
void run() { if (mDynamicUpdate == null) { mDraggableIcon.animate() .translationX(mDestX) .translationY(mDestY) .setDuration(mDuration) .setInterpolator(mInterpolator) .setListener(mAnimationFinishedListener); } else { ValueAnimator animator = ValueAnimator.ofInt(0, 100); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float percent = valueAnimator.getAnimatedFraction(); mDraggableIcon.setTranslationX(mDynamicUpdate.getTranslationX(percent)); mDraggableIcon.setTranslationY(mDynamicUpdate.getTranslationY(percent)); } }); animator.setDuration(mDuration); animator.setInterpolator(mInterpolator); animator.addListener(mAnimationFinishedListener); animator.start(); } }
Example 4
Source File: SmoothCheckBox.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
private void startCheckedAnimation() { ValueAnimator animator = ValueAnimator.ofFloat(1.0f, 0f); animator.setDuration(mAnimDuration / 3 * 2); animator.setInterpolator(new LinearInterpolator()); animator.addUpdateListener(animation -> { mScaleVal = (float) animation.getAnimatedValue(); mFloorColor = getGradientColor(mUnCheckedColor, mCheckedColor, 1 - mScaleVal); postInvalidate(); }); animator.start(); ValueAnimator floorAnimator = ValueAnimator.ofFloat(1.0f, 0.8f, 1.0f); floorAnimator.setDuration(mAnimDuration); floorAnimator.setInterpolator(new LinearInterpolator()); floorAnimator.addUpdateListener(animation -> { mFloorScale = (float) animation.getAnimatedValue(); postInvalidate(); }); floorAnimator.start(); drawTickDelayed(); }
Example 5
Source File: SplashActivity.java From ZZShow with Apache License 2.0 | 6 votes |
private void startLogoOuterAndAppName() { final ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1); valueAnimator.setDuration(1000); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float fraction = animation.getAnimatedFraction(); KLog.d("fraction: " + fraction); if (fraction >= 0.8 && !isShowingRubberEffect) { isShowingRubberEffect = true; startLogoOuter(); startShowAppName(); finishActivity(); } else if (fraction >= 0.95) { valueAnimator.cancel(); startLogoInner2(); } } }); valueAnimator.start(); }
Example 6
Source File: WheelPicker.java From RecyclerWheelPicker with Apache License 2.0 | 6 votes |
public void doEnterAnim(final View contentView, long animDuration) { if (builder.gravity == Gravity.BOTTOM) { ValueAnimator enterAnimator = ValueAnimator.ofFloat(contentView.getHeight(), 0); enterAnimator.setDuration(animDuration); enterAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); contentView.setTranslationY(value); } }); enterAnimator.start(); } else { ScaleAnimation scaleAnimation = new ScaleAnimation(0F, 1.0F, 0F, 1.0F, Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F); scaleAnimation.setDuration(animDuration); scaleAnimation.setFillAfter(true); contentView.startAnimation(scaleAnimation); } }
Example 7
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 6 votes |
private void openMenuDrawable(final DrawerArrowDrawable drawerArrowDrawable, boolean withAnim) { if (withAnim) { ValueAnimator anim = ValueAnimator.ofFloat(0.0f, 1.0f); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); drawerArrowDrawable.setProgress(value); } }); anim.setDuration(MENU_ICON_ANIM_DURATION); anim.start(); } else { drawerArrowDrawable.setProgress(1.0f); } }
Example 8
Source File: AnimHelper.java From DanDanPlayForAndroid with MIT License | 5 votes |
/** * 裁剪视图宽度 * @param view * @param srcHeight * @param endHeight 大概高度,用于动画展示 * @param duration */ public static void doClipViewHeight(final View view, int srcHeight, int endHeight, int duration) { ValueAnimator valueAnimator = ValueAnimator.ofInt(srcHeight, endHeight).setDuration(duration); valueAnimator.addUpdateListener(valueAnimator1 -> { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; view.setLayoutParams(layoutParams); }); valueAnimator.setInterpolator(new AccelerateInterpolator()); valueAnimator.start(); }
Example 9
Source File: Utils.java From Amphitheatre with Apache License 2.0 | 5 votes |
public static void animateColorChange(final View view, int colorFrom, int colorTo) { ValueAnimator valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer)animator.getAnimatedValue()); } }); valueAnimator.start(); }
Example 10
Source File: DragView.java From LB-Launcher with Apache License 2.0 | 5 votes |
public void crossFade(int duration) { ValueAnimator va = LauncherAnimUtils.ofFloat(this, 0f, 1f); va.setDuration(duration); va.setInterpolator(new DecelerateInterpolator(1.5f)); va.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mCrossFadeProgress = animation.getAnimatedFraction(); } }); va.start(); }
Example 11
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 5 votes |
private void fadeOutBackground() { ValueAnimator anim = ValueAnimator.ofInt(BACKGROUND_DRAWABLE_ALPHA_SEARCH_FOCUSED, BACKGROUND_DRAWABLE_ALPHA_SEARCH_NOT_FOCUSED); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (Integer) animation.getAnimatedValue(); mBackgroundDrawable.setAlpha(value); } }); anim.setDuration(BACKGROUND_FADE_ANIM_DURATION); anim.start(); }
Example 12
Source File: MainActivity.java From GoogleFitExample with Apache License 2.0 | 5 votes |
@Override public void onMenuExpanded() { overlay.clearAnimation(); float viewAlpha = overlay.getAlpha(); overlay.setVisibility(View.VISIBLE); ValueAnimator fadeAnim = ObjectAnimator.ofFloat(overlay, "alpha", viewAlpha, 1f); fadeAnim.setDuration(200L); fadeAnim.start(); }
Example 13
Source File: SpringFloatingActionMenu.java From SpringFloatingActionMenu with Apache License 2.0 | 5 votes |
private void fadeOut() { int colorFrom = Color.parseColor("#40000000"); int colorTo = Color.parseColor("#00000000"); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(250); // milliseconds colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); }
Example 14
Source File: DriveImageView.java From driveimageview with Apache License 2.0 | 5 votes |
/** * This a animates a "blend-in" animation of the figure. The duration can be customised. * * @param duration The duration in milliseconds */ public void animateText(int duration) { ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f); animation.setDuration(duration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { setAlphaValue((Float) valueAnimator.getAnimatedValue()); } }); animation.start(); }
Example 15
Source File: InkPageIndicator.java From Puff-Android with MIT License | 5 votes |
private void setSelectedPage(int now) { if (now == currentPage || now >= pageCount) return; pageChanging = true; previousPage = currentPage; currentPage = now; final int steps = Math.abs(now - previousPage); if (steps > 1) { if (now > previousPage) { for (int i = 0; i < steps; i++) { setJoiningFraction(previousPage + i, 1f); } } else { for (int i = -1; i > -steps; i--) { setJoiningFraction(previousPage + i, 1f); } } } // create the anim to move the selected dot – this animator will kick off // retreat animations when it has moved 75% of the way. // The retreat animation in turn will kick of reveal anims when the // retreat has passed any dots to be revealed ValueAnimator moveAnimation = createMoveSelectedAnimator(dotCenterX[now], previousPage, now, steps); moveAnimation.start(); }
Example 16
Source File: MainActivity.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 5 votes |
public void changeBackgroundColor(final View view, int from, int to) { int colorFrom = ContextCompat.getColor(this, from); int colorTo = ContextCompat.getColor(this, to); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(250); // milliseconds colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); }
Example 17
Source File: AlphaAnimation.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void start() { if (canAnimate && invalidate != null) { ValueAnimator animator = ValueAnimator.ofFloat(from, to); animator.setDuration(200); animator.setInterpolator(interpolator); animator.addUpdateListener(animation -> { animatedFraction = (float) animation.getAnimatedValue(); invalidate.run(); }); animator.start(); } }
Example 18
Source File: CircularSplashView.java From Depth with MIT License | 5 votes |
public void startAnim() { RectF startRect = new RectF(targetSize.centerX(), targetSize.centerY(), targetSize.centerX(), targetSize.centerY()); ValueAnimator rectSize = ValueAnimator.ofObject(new RectFEvaluator(), startRect, targetSize); rectSize.setDuration(animDuration); rectSize.setInterpolator(new QuintOut()); rectSize.setStartDelay(startDelay); rectSize.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { drawingRect = (RectF) animation.getAnimatedValue(); invalidate(); } }); rectSize.start(); }
Example 19
Source File: MediaView.java From Slide with GNU General Public License v3.0 | 4 votes |
public static void fadeIn(View l) { ValueAnimator mAnimator = fadeAnimator(0.66f, 1, l); mAnimator.start(); }
Example 20
Source File: SuperCardToast.java From Bitocle with Apache License 2.0 | 2 votes |
/** * Hide the SuperCardToast and animate the Layout. Post Honeycomb only. * */ @SuppressLint("NewApi") private void dismissWithLayoutAnimation() { if (mToastView != null) { mToastView.setVisibility(View.INVISIBLE); final ViewGroup.LayoutParams layoutParams = mToastView.getLayoutParams(); final int originalHeight = mToastView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1) .setDuration(mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime)); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { Handler mHandler = new Handler(); mHandler.post(mHideImmediateRunnable); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override @SuppressWarnings("ConstantConditions") public void onAnimationUpdate(ValueAnimator valueAnimator) { if (mToastView != null) { try { layoutParams.height = (Integer) valueAnimator.getAnimatedValue(); mToastView.setLayoutParams(layoutParams); } catch (NullPointerException e) { /* Do nothing */ } } } }); animator.start(); } else { dismissImmediately(); } }