List of usage examples for android.animation ObjectAnimator setInterpolator
@Override public void setInterpolator(TimeInterpolator value)
From source file:by.gdgminsk.animationguide.util.AnimUtils.java
public static void scaleIn(final View view, int delay) { view.setAlpha(0.0f);//from w w w .j av a2s.c o m view.setScaleX(0.0f); view.setScaleY(0.0f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); ObjectAnimator scaleInAnimation = ObjectAnimator.ofPropertyValuesHolder(view, alpha, scaleX, scaleY); scaleInAnimation.setDuration(view.getResources().getInteger(R.integer.duration_fab_scale_in)); scaleInAnimation.setStartDelay(delay); scaleInAnimation.setInterpolator(EASE_IN_INTERPOLATOR); scaleInAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { view.setAlpha(1.0f); view.setScaleX(1.0f); view.setScaleY(1.0f); } }); scaleInAnimation.start(); }
From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java
/** * Create a color change animation over a foreground property of a {@link FrameLayout}. * * @param target The target view.//ww w . jav a2s . c o m * @param startColorRes The color to start from. * @param targetColorRes The color this animation will end with. * @param interpolator The interpolator to use. * @return The color change animation. */ @NonNull public static ObjectAnimator createColorChange(@NonNull FrameLayout target, @ColorRes int startColorRes, @ColorRes int targetColorRes, @NonNull Interpolator interpolator) { Context context = target.getContext(); final int startColor = ContextCompat.getColor(context, startColorRes); final int targetColor = ContextCompat.getColor(context, targetColorRes); ObjectAnimator colorChange = ObjectAnimator.ofInt(target, ViewUtils.FOREGROUND_COLOR, startColor, targetColor); colorChange.setEvaluator(new ArgbEvaluator()); colorChange.setInterpolator(interpolator); colorChange.setDuration(context.getResources().getInteger(android.R.integer.config_longAnimTime)); return colorChange; }
From source file:com.ae.apps.messagecounter.fragments.SentCountFragment.java
/** * Sets the progress value to a progressbar, with animation if the OS supports it * /* w ww . j ava2 s.c om*/ * @param progressBar * @param progress */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void setProgressWithAnimation(ProgressBar progressBar, int progress, long animDelay) { // We try to add animation for newer APIs here if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.HONEYCOMB) { android.animation.ObjectAnimator animation = android.animation.ObjectAnimator.ofInt(progressBar, PROGRESS_VALUE, 0, progress); animation.setDuration(100); animation.setStartDelay(animDelay); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.start(); } else { progressBar.setProgress(progress); } }
From source file:com.miz.utils.ViewUtils.java
/** * Animates the transition when changing the maxLines * attribute of a TextView./*w w w. ja v a 2 s . co m*/ * @param text * @param maxLines */ public static void animateTextViewMaxLines(TextView text, int maxLines) { try { ObjectAnimator animation = ObjectAnimator.ofInt(text, "maxLines", maxLines); animation.setInterpolator(new AccelerateInterpolator()); animation.setDuration(200); animation.start(); } catch (Exception e) { // Some devices crash at runtime when using the ObjectAnimator text.setMaxLines(maxLines); } }
From source file:me.calebjones.spacelaunchnow.utils.Utils.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void animateViewColor(View v, int startColor, int endColor) { ObjectAnimator animator = ObjectAnimator.ofObject(v, "backgroundColor", new ArgbEvaluator(), startColor, endColor);// w ww . j av a2s . c o m animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f)); animator.setDuration(COLOR_ANIMATION_DURATION); animator.start(); }
From source file:com.fa.imaged.activity.DetailActivityV2.java
private static void animatePhotoLike() { detailvBgLike.setVisibility(View.VISIBLE); detailivLike.setVisibility(View.VISIBLE); detailvBgLike.setScaleY(0.1f);//from www . j a va2 s. co m detailvBgLike.setScaleX(0.1f); detailvBgLike.setAlpha(1f); detailivLike.setScaleY(0.1f); detailivLike.setScaleX(0.1f); AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleY", 0.1f, 1f); bgScaleYAnim.setDuration(200); bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleX", 0.1f, 1f); bgScaleXAnim.setDuration(200); bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(detailvBgLike, "alpha", 1f, 0f); bgAlphaAnim.setDuration(200); bgAlphaAnim.setStartDelay(150); bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 0.1f, 1f); imgScaleUpYAnim.setDuration(300); imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 0.1f, 1f); imgScaleUpXAnim.setDuration(300); imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 1f, 0f); imgScaleDownYAnim.setDuration(300); imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 1f, 0f); imgScaleDownXAnim.setDuration(300); imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR); animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim); animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim); animatorSet.start(); }
From source file:com.softminds.matrixcalculator.base_activities.faqs.java
@Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20); animator.setDuration(200);/*from w w w . jav a 2s . c o m*/ animator.setInterpolator(new DecelerateInterpolator()); animator.start(); view.performClick(); return true; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationZ", 0); animator2.setDuration(200); animator2.setInterpolator(new AccelerateInterpolator()); animator2.start(); return true; default: return false; } }
From source file:com.karthikb351.vitinfo2.customwidget.ScheduleView.java
public void setAttendance(int attendance) { ObjectAnimator animation = ObjectAnimator.ofInt(progressAttendance, "progress", attendance); animation.setDuration(1500);/*from w ww.j a v a 2 s . c o m*/ animation.setInterpolator(new DecelerateInterpolator()); animation.start(); if (attendance >= 80) { progressAttendance.setReachedBarColor(ContextCompat.getColor(getContext(), R.color.text_secondary)); progressAttendance.setProgressTextColor(ContextCompat.getColor(getContext(), R.color.text_secondary)); } else if (attendance < 75) { progressAttendance .setReachedBarColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light)); progressAttendance .setProgressTextColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light)); } else { progressAttendance.setReachedBarColor(ContextCompat.getColor(getContext(), R.color.midAttend)); progressAttendance.setProgressTextColor(ContextCompat.getColor(getContext(), R.color.midAttend)); } }
From source file:com.srinath.hcfab.under25hack.media.MediaFragment.java
public void onFabPressed(View view) { final float startX = mFab.getX(); AnimatorPath path = new AnimatorPath(); path.moveTo(0, 0);//from ww w .jav a 2 s. c om path.curveTo(-200, 200, -400, 100, -600, 50); final ObjectAnimator anim = ObjectAnimator.ofObject(this, "fabLoc", new PathEvaluator(), path.getPoints().toArray()); anim.setInterpolator(new AccelerateInterpolator()); anim.setDuration(ANIMATION_DURATION); anim.start(); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (Math.abs(startX - mFab.getX()) > MINIMUN_X_DISTANCE) { if (!mRevealFlag) { mFabContainer.setY(mFabContainer.getY() + mFabSize / 2); mFab.animate().scaleXBy(SCALE_FACTOR).scaleYBy(SCALE_FACTOR).setListener(mEndRevealListener) .setDuration(ANIMATION_DURATION); mRevealFlag = true; } } } }); }
From source file:com.karthikb351.vitinfo2.fragment.courses.CourseListAdapter.java
public void setAttendance(CourseViewHolder courseViewHolder, int attendance) { ObjectAnimator animation = ObjectAnimator.ofInt(courseViewHolder.numberProgressBar, "progress", attendance); animation.setDuration(1500);// ww w .j a v a2s .c o m animation.setInterpolator(new DecelerateInterpolator()); animation.start(); if (attendance >= 80) { courseViewHolder.numberProgressBar .setReachedBarColor(ContextCompat.getColor(this.context, R.color.text_secondary)); courseViewHolder.numberProgressBar .setProgressTextColor(ContextCompat.getColor(this.context, R.color.text_secondary)); } else if (attendance < 75) { courseViewHolder.numberProgressBar .setReachedBarColor(ContextCompat.getColor(this.context, android.R.color.holo_red_light)); courseViewHolder.numberProgressBar .setProgressTextColor(ContextCompat.getColor(this.context, android.R.color.holo_red_light)); } else { courseViewHolder.numberProgressBar .setReachedBarColor(ContextCompat.getColor(this.context, R.color.midAttend)); courseViewHolder.numberProgressBar .setProgressTextColor(ContextCompat.getColor(this.context, R.color.midAttend)); } }