ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar); ObjectAnimator animation = ObjectAnimator.ofInt (progressBar, "progress", 0, 500); // see this max value coming back here, we animale towards that value animation.setDuration (5000); //in milliseconds animation.setInterpolator (new DecelerateInterpolator ()); animation.start ();
if(android.os.Build.VERSION.SDK_INT >= 11){ // will update the "progress" propriety of seekbar until it reaches progress ObjectAnimator animation = ObjectAnimator.ofInt(seekbar, "progress", progress); animation.setDuration(500); // 0.5 second animation.setInterpolator(new DecelerateInterpolator()); animation.start(); } else seekbar.setProgress(progress); // no animation on Gingerbread or lower
@RequiresApi(11) private ObjectAnimator yAnimator(int duration, EasingFunction easing) { ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f); animatorY.setInterpolator(easing); animatorY.setDuration(duration); return animatorY; }
@RequiresApi(11) private ObjectAnimator xAnimator(int duration, EasingFunction easing) { ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f); animatorX.setInterpolator(easing); animatorX.setDuration(duration); return animatorX; }
private void setupSimulateProgressAnimator() { simulateProgressAnimator = ObjectAnimator.ofFloat(this, "currentProgress", 0, 100).setDuration(2000); simulateProgressAnimator.setInterpolator(new AccelerateInterpolator()); simulateProgressAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_DONE_STARTED); } }); }
public void reset() { final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "percent", 1f, 0f); objectAnimator.setDuration(duration); if (interpolator != null) { objectAnimator.setInterpolator(interpolator); } objectAnimator.start(); }
private void setupDoneAnimators() { doneBgAnimator = ObjectAnimator.ofFloat(this, "currentDoneBgOffset", MAX_DONE_BG_OFFSET, 0).setDuration(300); doneBgAnimator.setInterpolator(new DecelerateInterpolator()); checkmarkAnimator = ObjectAnimator.ofFloat(this, "currentCheckmarkOffset", MAX_DONE_IMG_OFFSET, 0).setDuration(300); checkmarkAnimator.setInterpolator(new OvershootInterpolator()); checkmarkAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_FINISHED); } }); }
void finishSpotlight(long duration, TimeInterpolator animation, AbstractAnimatorListener listener) { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f); objectAnimator.setDuration(duration); objectAnimator.setInterpolator(animation); objectAnimator.addListener(listener); objectAnimator.start(); }
public void initRotateAnimation(float start) { mObjectAnimator = ObjectAnimator.ofFloat(this, "rotation", start, 360f + start); mObjectAnimator.setDuration(DEFAULT_DURATION); mObjectAnimator.setInterpolator(new LinearInterpolator()); mObjectAnimator.setRepeatCount(ObjectAnimator.INFINITE); }
@Override protected Animator createSoftwareEnter(boolean fast) { // Linear enter based on current opacity. final int maxDuration = fast ? OPACITY_ENTER_DURATION_FAST : OPACITY_ENTER_DURATION; final int duration = (int) ((1 - mOpacity) * maxDuration); final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 1); AnimatorsCompat.setAutoCancel(opacity); //opacity.setAutoCancel(true); opacity.setDuration(duration); opacity.setInterpolator(LINEAR_INTERPOLATOR); return opacity; }
protected ObjectAnimator createSlowdownAnimator(View view, int slowdownDuration, float slowdownEndOffset) { ObjectAnimator slowdownAnim = ObjectAnimator.ofFloat(view, mAnimAttributes.mProperty, slowdownEndOffset); slowdownAnim.setDuration(slowdownDuration); slowdownAnim.setInterpolator(mBounceBackInterpolator); slowdownAnim.addUpdateListener(this); return slowdownAnim; }
/** * Applys a spin animation to the Chart. * * @param durationmillis * @param fromangle * @param toangle */ @SuppressLint("NewApi") public void spin(int durationmillis, float fromangle, float toangle, EasingFunction easing) { setRotationAngle(fromangle); ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle, toangle); spinAnimator.setDuration(durationmillis); spinAnimator.setInterpolator(easing); spinAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { postInvalidate(); } }); spinAnimator.start(); } }
protected ObjectAnimator createBounceBackAnimator(float startOffset) { final View view = mViewAdapter.getView(); // Duration is proportional to the view's size. float bounceBackDuration = (Math.abs(startOffset) / mAnimAttributes.mMaxOffset) * MAX_BOUNCE_BACK_DURATION_MS; ObjectAnimator bounceBackAnim = ObjectAnimator.ofFloat(view, mAnimAttributes.mProperty, mStartAttr.mAbsOffset); bounceBackAnim.setDuration(Math.max((int) bounceBackDuration, MIN_BOUNCE_BACK_DURATION_MS)); bounceBackAnim.setInterpolator(mBounceBackInterpolator); bounceBackAnim.addUpdateListener(this); return bounceBackAnim; } }
private void resizeViewProperty(Property<View, Float> property, float targetScale, int durationOffset) { ObjectAnimator animator = ObjectAnimator.ofFloat(this, property, 1f, targetScale); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setStartDelay(DELAY_COLOR_CHANGE + durationOffset); animator.start(); }
private void startHover() { if (eventCancelled) return; if (hoverAnimator != null) { hoverAnimator.cancel(); } final float radius = (float) (Math.sqrt(Math.pow(getWidth(), 2) + Math.pow(getHeight(), 2)) * 1.2f); hoverAnimator = ObjectAnimator.ofFloat(this, radiusProperty, rippleDiameter, radius) .setDuration(HOVER_DURATION); hoverAnimator.setInterpolator(new LinearInterpolator()); hoverAnimator.start(); }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); LinearLayout progressbarLayout = (LinearLayout) findViewById(R.id.progressbar_layout); progressbarLayout.setTranslationY(-mLayoutHeight); progressbarLayout.setVisibility(VISIBLE); ObjectAnimator animator = ObjectAnimator.ofFloat(progressbarLayout, "translationY", -mLayoutHeight, 0); animator.setInterpolator(new DecelerateInterpolator()); animator.setDuration(500); animator.start(); }
@Override public void onStart() { super.onStart(); // animatorWeakReference = new WeakReference<ObjectAnimator>(new ObjectAnimator()); // animator = animatorWeakReference.get(); animatorWeakReference = new WeakReference(ObjectAnimator.ofFloat(getView(), "rotation", new float[]{0.0F, 360.0F})); animator = animatorWeakReference.get(); //animator = ObjectAnimator.ofFloat(getView(), "rotation", new float[]{0.0F, 360.0F}); animator.setRepeatCount(Integer.MAX_VALUE); animator.setDuration(25000L); animator.setInterpolator(new LinearInterpolator()); if (getView() != null) getView().setTag(R.id.tag_animator, this.animator); }
@SuppressWarnings("deprecation") public void closeToolbar() { closeMenu(); ObjectAnimator animator = ObjectAnimator.ofFloat(mToolbar, "translationX", mToolbar.getTranslationX(), mToolbarWidth); animator.setInterpolator(new DecelerateInterpolator()); animator.start(); mToggleButton.setImageDrawable( getResources().getDrawable(R.drawable.ic_chevron_left_white_24dp)); }
public void startFromLocation(int[] tapLocationOnScreen) { changeState(STATE_FILL_STARTED); startLocationX = tapLocationOnScreen[0]; startLocationY = tapLocationOnScreen[1]; revealAnimator = ObjectAnimator.ofInt(this, "currentRadius", 0, getWidth() + getHeight()).setDuration(FILL_TIME); revealAnimator.setInterpolator(INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_FINISHED); } }); revealAnimator.start(); }
private ObjectAnimator getTitleAnimator() { if (mAnimator == null) { if (mCurTitleProperty == null) mCurTitleProperty = new TitleProperty(); mAnimator = ObjectAnimator.ofObject(this, TITLE_PROPERTY, new TitleEvaluator(mCurTitleProperty), mCurTitleProperty); mAnimator.setDuration(ANIMATION_DURATION); mAnimator.setInterpolator(ANIMATION_INTERPOLATOR); } else { mAnimator.cancel(); } return mAnimator; }