Here are the examples of the java api class android.animation.PropertyValuesHolder taken from open source projects.
1. SlideAndZoomTransitionFactory#getOutAnimator()
Project: android-slideshow-widget
File: SlideAndZoomTransitionFactory.java
File: SlideAndZoomTransitionFactory.java
@Override public Animator getOutAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { final PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, 0, -parent.getWidth() / 3, -parent.getWidth()); final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1.0f, 0.6f, 0.5f); final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.0f, 0.6f, 0.5f); final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1, 1, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, translationX, scaleX, scaleY, alpha); animator.setDuration(getDuration()); animator.setInterpolator(getInterpolator()); return animator; }
2. SlideAndZoomTransitionFactory#getInAnimator()
Project: android-slideshow-widget
File: SlideAndZoomTransitionFactory.java
File: SlideAndZoomTransitionFactory.java
//============================================================================================== // INTERFACE IMPLEMENTATION: SlideTransitionFactory //== @Override public Animator getInAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { target.setAlpha(0); target.setScaleX(1); target.setScaleY(1); target.setTranslationX(0); target.setTranslationY(0); target.setRotationX(0); target.setRotationY(0); final PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, parent.getWidth(), parent.getWidth() / 3, 0); final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.5f, 0.6f, 1.0f); final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.5f, 0.6f, 1.0f); final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0, 1, 1); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, translationX, scaleX, scaleY, alpha); animator.setDuration(getDuration()); animator.setInterpolator(getInterpolator()); return animator; }
3. ZoomTransitionFactory#getOutAnimator()
Project: android-slideshow-widget
File: ZoomTransitionFactory.java
File: ZoomTransitionFactory.java
@Override public Animator getOutAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, SCALE_FACTOR); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, SCALE_FACTOR); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, scaleX, scaleY, alpha); animator.setDuration(getDuration()); animator.setInterpolator(getInterpolator()); return animator; }
4. ZoomTransitionFactory#getInAnimator()
Project: android-slideshow-widget
File: ZoomTransitionFactory.java
File: ZoomTransitionFactory.java
//============================================================================================== // INTERFACE IMPLEMENTATION: SlideTransitionFactory //== @Override public Animator getInAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { target.setAlpha(0); target.setScaleX(SCALE_FACTOR); target.setScaleY(SCALE_FACTOR); target.setTranslationX(0); target.setTranslationY(0); target.setRotationX(0); target.setRotationY(0); final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1); final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1); final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, scaleX, scaleY, alpha); animator.setDuration(getDuration()); animator.setInterpolator(getInterpolator()); return animator; }
5. AniUtils#scaleIn()
Project: WordPress-Android
File: AniUtils.java
File: AniUtils.java
public static void scaleIn(final View target, Duration duration) { if (target == null || duration == null) { return; } PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, scaleX, scaleY); animator.setDuration(duration.toMillis(target.getContext())); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { target.setVisibility(View.VISIBLE); } }); animator.start(); }
6. Utils#getPulseAnimator()
Project: uhabits
File: Utils.java
File: Utils.java
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
7. AlarmRingingFragment#initializeClockAnimation()
Project: ProjectOxford-Apps-MimickerAlarm
File: AlarmRingingFragment.java
File: AlarmRingingFragment.java
private void initializeClockAnimation(View view) { // Show a growing clock and then shrinking again repeatedly PropertyValuesHolder scaleXAnimation = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 1.2f, 1f); PropertyValuesHolder scaleYAnimation = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 1.2f, 1f); mClockAnimation = ObjectAnimator.ofPropertyValuesHolder(mAlarmRingingClock, scaleXAnimation, scaleYAnimation); mClockAnimation.setDuration(CLOCK_ANIMATION_DURATION); mClockAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); mClockAnimation.setRepeatCount(ValueAnimator.INFINITE); mLeftArrowImage = (ImageView) view.findViewById(R.id.alarm_ringing_left_arrow); mLeftArrowImage.setBackgroundResource(R.drawable.ringing_left_arrow_animation); mRightArrowImage = (ImageView) view.findViewById(R.id.alarm_ringing_right_arrow); mRightArrowImage.setBackgroundResource(R.drawable.ringing_right_arrow_animation); mLeftArrowAnimation = (AnimationDrawable) mLeftArrowImage.getBackground(); mRightArrowAnimation = (AnimationDrawable) mRightArrowImage.getBackground(); }
8. Utils#getPulseAnimator()
Project: NotePad
File: Utils.java
File: Utils.java
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
9. Utils#getPulseAnimator()
Project: narrate-android
File: Utils.java
File: Utils.java
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
10. ClockView#startNewSteadyAnim()
Project: MiClockView
File: ClockView.java
File: ClockView.java
private void startNewSteadyAnim() { final String propertyNameRotateX = "canvasRotateX"; final String propertyNameRotateY = "canvasRotateY"; PropertyValuesHolder holderRotateX = PropertyValuesHolder.ofFloat(propertyNameRotateX, canvasRotateX, 0); PropertyValuesHolder holderRotateY = PropertyValuesHolder.ofFloat(propertyNameRotateY, canvasRotateY, 0); steadyAnim = ValueAnimator.ofPropertyValuesHolder(holderRotateX, holderRotateY); steadyAnim.setDuration(1000); steadyAnim.setInterpolator(new BounceInterpolator()); steadyAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { canvasRotateX = (float) animation.getAnimatedValue(propertyNameRotateX); canvasRotateY = (float) animation.getAnimatedValue(propertyNameRotateY); } }); steadyAnim.start(); }
11. Utils#getPulseAnimator()
Project: MaterialDateTimePicker
File: Utils.java
File: Utils.java
/** * Takes a number of weeks since the epoch and calculates the Julian day of * the Monday for that week. * * This assumes that the week containing the {@link Time#EPOCH_JULIAN_DAY} * is considered week 0. It returns the Julian day for the Monday * {@code week} weeks after the Monday of the week containing the epoch. * * @param week Number of weeks since the epoch * @return The julian day for the Monday of the given week since the epoch */ /** public static int getJulianMondayFromWeeksSinceEpoch(int week) { return MONDAY_BEFORE_JULIAN_EPOCH + week * 7; } */ /** * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970) * adjusted for first day of week. * * This takes a julian day and the week start day and calculates which * week since {@link Time#EPOCH_JULIAN_DAY} that day occurs in, starting * at 0. *Do not* use this to compute the ISO week number for the year. * * @param julianDay The julian day to calculate the week number for * @param firstDayOfWeek Which week day is the first day of the week, * see {@link Time#SUNDAY} * @return Weeks since the epoch */ /** public static int getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek) { int diff = Time.THURSDAY - firstDayOfWeek; if (diff < 0) { diff += 7; } int refDay = Time.EPOCH_JULIAN_DAY - diff; return (julianDay - refDay) / 7; } */ /** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
12. Utils#getPulseAnimator()
Project: MaterialDateRangePicker
File: Utils.java
File: Utils.java
/** * Takes a number of weeks since the epoch and calculates the Julian day of * the Monday for that week. * * This assumes that the week containing the {@link Time#EPOCH_JULIAN_DAY} * is considered week 0. It returns the Julian day for the Monday * {@code week} weeks after the Monday of the week containing the epoch. * * @param week Number of weeks since the epoch * @return The julian day for the Monday of the given week since the epoch */ /** public static int getJulianMondayFromWeeksSinceEpoch(int week) { return MONDAY_BEFORE_JULIAN_EPOCH + week * 7; } */ /** * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970) * adjusted for first day of week. * * This takes a julian day and the week start day and calculates which * week since {@link Time#EPOCH_JULIAN_DAY} that day occurs in, starting * at 0. *Do not* use this to compute the ISO week number for the year. * * @param julianDay The julian day to calculate the week number for * @param firstDayOfWeek Which week day is the first day of the week, * see {@link Time#SUNDAY} * @return Weeks since the epoch */ /** public static int getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek) { int diff = Time.THURSDAY - firstDayOfWeek; if (diff < 0) { diff += 7; } int refDay = Time.EPOCH_JULIAN_DAY - diff; return (julianDay - refDay) / 7; } */ /** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
13. MultiplePropertyFragment#prepareAnimator()
Project: AnimatorDemo
File: MultiplePropertyFragment.java
File: MultiplePropertyFragment.java
@Override protected Animator prepareAnimator(int width, int height) { anim = new ValueAnimator(); PropertyValuesHolder pX = PropertyValuesHolder.ofInt("x", width, 0); PropertyValuesHolder pY = PropertyValuesHolder.ofInt("y", 0, height); anim.setValues(pX, pY); paint = new Paint(); paint.setColor(Color.DKGRAY); anim.setDuration(5000); return anim; }
14. AnimationUtils#nope()
Project: UltimateAndroid
File: AnimationUtils.java
File: AnimationUtils.java
public static ObjectAnimator nope(View view) { // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium); int delta = 40; PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500); }
15. AnimationUtils#leftRightShake()
Project: UltimateAndroid
File: AnimationUtils.java
File: AnimationUtils.java
/** * Shake the view from left to right * * @param view * @return */ public static ObjectAnimator leftRightShake(View view) { // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium); int delta = 40; PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500); }
16. RadialTimePickerView#getFadeInAnimator()
Project: SublimePicker
File: RadialTimePickerView.java
File: RadialTimePickerView.java
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { final float delayMultiplier = 0.25f; final float transitionDurationMultiplier = 1f; final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier); final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration; final Keyframe kf0, kf1, kf2; kf0 = Keyframe.ofInt(0f, startAlpha); kf1 = Keyframe.ofInt(delayPoint, startAlpha); kf2 = Keyframe.ofInt(1f, endAlpha); final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2); final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn); animator.setDuration(totalDuration); animator.addUpdateListener(updateListener); return animator; }
17. Tooltip#setEnterAnimation()
Project: NBAPlus
File: Tooltip.java
File: Tooltip.java
/** * * @param values * @return */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public ObjectAnimator setEnterAnimation(PropertyValuesHolder... values) { for (PropertyValuesHolder value : values) { if (value.getPropertyName().equals("alpha")) setAlpha(0); if (value.getPropertyName().equals("rotation")) setRotation(0); if (value.getPropertyName().equals("rotationX")) setRotationX(0); if (value.getPropertyName().equals("rotationY")) setRotationY(0); if (value.getPropertyName().equals("translationX")) setTranslationX(0); if (value.getPropertyName().equals("translationY")) setTranslationY(0); if (value.getPropertyName().equals("scaleX")) setScaleX(0); if (value.getPropertyName().equals("scaleY")) setScaleY(0); } return mEnterAnimator = ObjectAnimator.ofPropertyValuesHolder(this, values); }
18. Views#nopeAnimation()
Project: CameraColorPicker
File: Views.java
File: Views.java
/** * Credit goes to Cyril Mottier. * https://plus.google.com/+CyrilMottier/posts/FABaJhRMCuy * * @param view the {@link View} to animate. * @return an {@link ObjectAnimator} that will play a 'nope' animation. */ public static ObjectAnimator nopeAnimation(View view, int delta) { PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500); }
19. RadialTimePickerView#getFadeInAnimator()
Project: AppCompat-Extension-Library
File: RadialTimePickerView.java
File: RadialTimePickerView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { final float delayMultiplier = 0.25f; final float transitionDurationMultiplier = 1f; final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier); final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration; final Keyframe kf0, kf1, kf2; kf0 = Keyframe.ofInt(0f, startAlpha); kf1 = Keyframe.ofInt(delayPoint, startAlpha); kf2 = Keyframe.ofInt(1f, endAlpha); final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2); final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn); animator.setDuration(totalDuration); animator.addUpdateListener(updateListener); return animator; }
20. LayoutAnimationsHideShow#setupCustomAnimations()
Project: codeexamples-android
File: LayoutAnimationsHideShow.java
File: LayoutAnimationsHideShow.java
private void setupCustomAnimations() { // Changing while Adding PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); final ObjectAnimator changeIn = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(mTransitioner.getDuration(LayoutTransition.CHANGE_APPEARING)); mTransitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, changeIn); changeIn.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setScaleX(1f); view.setScaleY(1f); } }); // Changing while Removing Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); final ObjectAnimator changeOut = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(mTransitioner.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); mTransitioner.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changeOut); changeOut.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotation(0f); } }); // Adding ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(mTransitioner.getDuration(LayoutTransition.APPEARING)); mTransitioner.setAnimator(LayoutTransition.APPEARING, animIn); animIn.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationY(0f); } }); // Removing ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(mTransitioner.getDuration(LayoutTransition.DISAPPEARING)); mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut); animOut.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationX(0f); } }); }
21. LayoutAnimations#createCustomAnimations()
Project: codeexamples-android
File: LayoutAnimations.java
File: LayoutAnimations.java
private void createCustomAnimations(LayoutTransition transition) { // Changing while Adding PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); customChangingAppearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(transition.getDuration(LayoutTransition.CHANGE_APPEARING)); customChangingAppearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setScaleX(1f); view.setScaleY(1f); } }); // Changing while Removing Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); customChangingDisappearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); customChangingDisappearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotation(0f); } }); // Adding customAppearingAnim = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(transition.getDuration(LayoutTransition.APPEARING)); customAppearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationY(0f); } }); // Removing customDisappearingAnim = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(transition.getDuration(LayoutTransition.DISAPPEARING)); customDisappearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationX(0f); } }); }
22. LayoutAnimHideShowActivity#setupCustomAnimations()
Project: AndroidStudyDemo
File: LayoutAnimHideShowActivity.java
File: LayoutAnimHideShowActivity.java
// ??????? private void setupCustomAnimations() { // ???CHANGE_APPEARING // Changing while Adding PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); final ObjectAnimator changeIn = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(mTransitioner.getDuration(LayoutTransition.CHANGE_APPEARING)); mTransitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, changeIn); changeIn.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setScaleX(1f); view.setScaleY(1f); } }); // ???CHANGE_DISAPPEARING // Changing while Removing Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); final ObjectAnimator changeOut = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(mTransitioner.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); mTransitioner.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changeOut); changeOut.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotation(0f); } }); // ???APPEARING // Adding ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(mTransitioner.getDuration(LayoutTransition.APPEARING)); mTransitioner.setAnimator(LayoutTransition.APPEARING, animIn); animIn.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationY(0f); } }); // ???DISAPPEARING // Removing ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(mTransitioner.getDuration(LayoutTransition.DISAPPEARING)); mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut); animOut.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationX(0f); } }); }
23. LayoutAnimActivity#createCustomAnimations()
Project: AndroidStudyDemo
File: LayoutAnimActivity.java
File: LayoutAnimActivity.java
// ??????? private void createCustomAnimations(LayoutTransition transition) { // Changing while Adding // ???????? PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); // ????ChangingAppearing?? // ?????????????? mCustomChangingAppearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(transition.getDuration(LayoutTransition.CHANGE_APPEARING)); mCustomChangingAppearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setScaleX(1f); view.setScaleY(1f); } }); // ????ChangingDisappearing?? // ??????? // Changing while Removing Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); mCustomChangingDisappearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); mCustomChangingDisappearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotation(0f); } }); // ????Appearing?????????Y??????? // Adding mCustomAppearingAnim = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(transition.getDuration(LayoutTransition.APPEARING)); mCustomAppearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationY(0f); } }); // ????Disappearing?????????X??????? // Removing mCustomDisappearingAnim = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(transition.getDuration(LayoutTransition.DISAPPEARING)); mCustomDisappearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationX(0f); } }); }
24. LayoutAnimationsHideShow#setupCustomAnimations()
Project: android-maven-plugin
File: LayoutAnimationsHideShow.java
File: LayoutAnimationsHideShow.java
private void setupCustomAnimations() { // Changing while Adding PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); final ObjectAnimator changeIn = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(mTransitioner.getDuration(LayoutTransition.CHANGE_APPEARING)); mTransitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, changeIn); changeIn.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setScaleX(1f); view.setScaleY(1f); } }); // Changing while Removing Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); final ObjectAnimator changeOut = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(mTransitioner.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); mTransitioner.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changeOut); changeOut.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotation(0f); } }); // Adding ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(mTransitioner.getDuration(LayoutTransition.APPEARING)); mTransitioner.setAnimator(LayoutTransition.APPEARING, animIn); animIn.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationY(0f); } }); // Removing ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(mTransitioner.getDuration(LayoutTransition.DISAPPEARING)); mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut); animOut.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationX(0f); } }); }
25. LayoutAnimations#createCustomAnimations()
Project: android-maven-plugin
File: LayoutAnimations.java
File: LayoutAnimations.java
private void createCustomAnimations(LayoutTransition transition) { // Changing while Adding PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); customChangingAppearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(transition.getDuration(LayoutTransition.CHANGE_APPEARING)); customChangingAppearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setScaleX(1f); view.setScaleY(1f); } }); // Changing while Removing Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); customChangingDisappearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); customChangingDisappearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotation(0f); } }); // Adding customAppearingAnim = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(transition.getDuration(LayoutTransition.APPEARING)); customAppearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationY(0f); } }); // Removing customDisappearingAnim = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(transition.getDuration(LayoutTransition.DISAPPEARING)); customDisappearingAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator anim) { View view = (View) ((ObjectAnimator) anim).getTarget(); view.setRotationX(0f); } }); }
26. ShadowView#changeZDepth()
Project: ZDepthShadow
File: ShadowView.java
File: ShadowView.java
protected void changeZDepth(ZDepth zDepth) { int newAlphaTopShadow = zDepth.getAlphaTopShadow(); int newAlphaBottomShadow = zDepth.getAlphaBottomShadow(); float newOffsetYTopShadow = zDepth.getOffsetYTopShadowPx(getContext()); float newOffsetYBottomShadow = zDepth.getOffsetYBottomShadowPx(getContext()); float newBlurTopShadow = zDepth.getBlurTopShadowPx(getContext()); float newBlurBottomShadow = zDepth.getBlurBottomShadowPx(getContext()); if (!mZDepthDoAnimation) { mZDepthParam.mAlphaTopShadow = newAlphaTopShadow; mZDepthParam.mAlphaBottomShadow = newAlphaBottomShadow; mZDepthParam.mOffsetYTopShadowPx = newOffsetYTopShadow; mZDepthParam.mOffsetYBottomShadowPx = newOffsetYBottomShadow; mZDepthParam.mBlurTopShadowPx = newBlurTopShadow; mZDepthParam.mBlurBottomShadowPx = newBlurBottomShadow; mShadow.setParameter(mZDepthParam, mZDepthPaddingLeft, mZDepthPaddingTop, getWidth() - mZDepthPaddingRight, getHeight() - mZDepthPaddingBottom); invalidate(); return; } int nowAlphaTopShadow = mZDepthParam.mAlphaTopShadow; int nowAlphaBottomShadow = mZDepthParam.mAlphaBottomShadow; float nowOffsetYTopShadow = mZDepthParam.mOffsetYTopShadowPx; float nowOffsetYBottomShadow = mZDepthParam.mOffsetYBottomShadowPx; float nowBlurTopShadow = mZDepthParam.mBlurTopShadowPx; float nowBlurBottomShadow = mZDepthParam.mBlurBottomShadowPx; PropertyValuesHolder alphaTopShadowHolder = PropertyValuesHolder.ofInt(ANIM_PROPERTY_ALPHA_TOP_SHADOW, nowAlphaTopShadow, newAlphaTopShadow); PropertyValuesHolder alphaBottomShadowHolder = PropertyValuesHolder.ofInt(ANIM_PROPERTY_ALPHA_BOTTOM_SHADOW, nowAlphaBottomShadow, newAlphaBottomShadow); PropertyValuesHolder offsetTopShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_OFFSET_TOP_SHADOW, nowOffsetYTopShadow, newOffsetYTopShadow); PropertyValuesHolder offsetBottomShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_OFFSET_BOTTOM_SHADOW, nowOffsetYBottomShadow, newOffsetYBottomShadow); PropertyValuesHolder blurTopShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_BLUR_TOP_SHADOW, nowBlurTopShadow, newBlurTopShadow); PropertyValuesHolder blurBottomShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_BLUR_BOTTOM_SHADOW, nowBlurBottomShadow, newBlurBottomShadow); ValueAnimator anim = ValueAnimator.ofPropertyValuesHolder(alphaTopShadowHolder, alphaBottomShadowHolder, offsetTopShadowHolder, offsetBottomShadowHolder, blurTopShadowHolder, blurBottomShadowHolder); anim.setDuration(mZDepthAnimDuration); anim.setInterpolator(new LinearInterpolator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int alphaTopShadow = (Integer) animation.getAnimatedValue(ANIM_PROPERTY_ALPHA_TOP_SHADOW); int alphaBottomShadow = (Integer) animation.getAnimatedValue(ANIM_PROPERTY_ALPHA_BOTTOM_SHADOW); float offsetTopShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_OFFSET_TOP_SHADOW); float offsetBottomShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_OFFSET_BOTTOM_SHADOW); float blurTopShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_BLUR_TOP_SHADOW); float blurBottomShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_BLUR_BOTTOM_SHADOW); mZDepthParam.mAlphaTopShadow = alphaTopShadow; mZDepthParam.mAlphaBottomShadow = alphaBottomShadow; mZDepthParam.mOffsetYTopShadowPx = offsetTopShadow; mZDepthParam.mOffsetYBottomShadowPx = offsetBottomShadow; mZDepthParam.mBlurTopShadowPx = blurTopShadow; mZDepthParam.mBlurBottomShadowPx = blurBottomShadow; mShadow.setParameter(mZDepthParam, mZDepthPaddingLeft, mZDepthPaddingTop, getWidth() - mZDepthPaddingRight, getHeight() - mZDepthPaddingBottom); invalidate(); } }); anim.start(); }
27. AllAnimation#waveAnimation()
Project: android-different-loading-animations
File: AllAnimation.java
File: AllAnimation.java
public void waveAnimation() { PropertyValuesHolder tvOne_Y = PropertyValuesHolder.ofFloat(hangoutTvOne.TRANSLATION_Y, -40.0f); PropertyValuesHolder tvOne_X = PropertyValuesHolder.ofFloat(hangoutTvOne.TRANSLATION_X, 0); waveOneAnimator = ObjectAnimator.ofPropertyValuesHolder(hangoutTvOne, tvOne_X, tvOne_Y); waveOneAnimator.setRepeatCount(-1); waveOneAnimator.setRepeatMode(ValueAnimator.REVERSE); waveOneAnimator.setDuration(300); waveOneAnimator.start(); PropertyValuesHolder tvTwo_Y = PropertyValuesHolder.ofFloat(hangoutTvTwo.TRANSLATION_Y, -40.0f); PropertyValuesHolder tvTwo_X = PropertyValuesHolder.ofFloat(hangoutTvTwo.TRANSLATION_X, 0); waveTwoAnimator = ObjectAnimator.ofPropertyValuesHolder(hangoutTvTwo, tvTwo_X, tvTwo_Y); waveTwoAnimator.setRepeatCount(-1); waveTwoAnimator.setRepeatMode(ValueAnimator.REVERSE); waveTwoAnimator.setDuration(300); waveTwoAnimator.setStartDelay(100); waveTwoAnimator.start(); PropertyValuesHolder tvThree_Y = PropertyValuesHolder.ofFloat(hangoutTvThree.TRANSLATION_Y, -40.0f); PropertyValuesHolder tvThree_X = PropertyValuesHolder.ofFloat(hangoutTvThree.TRANSLATION_X, 0); waveThreeAnimator = ObjectAnimator.ofPropertyValuesHolder(hangoutTvThree, tvThree_X, tvThree_Y); waveThreeAnimator.setRepeatCount(-1); waveThreeAnimator.setRepeatMode(ValueAnimator.REVERSE); waveThreeAnimator.setDuration(300); waveThreeAnimator.setStartDelay(200); waveThreeAnimator.start(); }
28. TextResize#createAnimator()
Project: android-unsplash
File: TextResize.java
File: TextResize.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (startValues == null || endValues == null) { return null; } final TextResizeData startData = (TextResizeData) startValues.values.get(DATA); final TextResizeData endData = (TextResizeData) endValues.values.get(DATA); if (startData.gravity != endData.gravity) { // Can't deal with changes in gravity return null; } final TextView textView = (TextView) endValues.view; float startFontSize = (Float) startValues.values.get(FONT_SIZE); // Capture the start bitmap -- we need to set the values to the start values first setTextViewData(textView, startData, startFontSize); final float startWidth = textView.getPaint().measureText(textView.getText().toString()); final Bitmap startBitmap = captureTextBitmap(textView); if (startBitmap == null) { startFontSize = 0; } float endFontSize = (Float) endValues.values.get(FONT_SIZE); // Set the values to the end values setTextViewData(textView, endData, endFontSize); final float endWidth = textView.getPaint().measureText(textView.getText().toString()); // Capture the end bitmap final Bitmap endBitmap = captureTextBitmap(textView); if (endBitmap == null) { endFontSize = 0; } if (startFontSize == 0 && endFontSize == 0) { // Can't animate null bitmaps return null; } // Set the colors of the TextView so that nothing is drawn. // Only draw the bitmaps in the overlay. final ColorStateList textColors = textView.getTextColors(); final ColorStateList hintColors = textView.getHintTextColors(); final int highlightColor = textView.getHighlightColor(); final ColorStateList linkColors = textView.getLinkTextColors(); textView.setTextColor(Color.TRANSPARENT); textView.setHintTextColor(Color.TRANSPARENT); textView.setHighlightColor(Color.TRANSPARENT); textView.setLinkTextColor(Color.TRANSPARENT); // Create the drawable that will be animated in the TextView's overlay. // Ensure that it is showing the start state now. final SwitchBitmapDrawable drawable = new SwitchBitmapDrawable(textView, startData.gravity, startBitmap, startFontSize, startWidth, endBitmap, endFontSize, endWidth); textView.getOverlay().add(drawable); // Properties: left, top, font size, text color final PropertyValuesHolder leftProp = PropertyValuesHolder.ofFloat("left", startData.paddingLeft, endData.paddingLeft); final PropertyValuesHolder topProp = PropertyValuesHolder.ofFloat("top", startData.paddingTop, endData.paddingTop); final PropertyValuesHolder rightProp = PropertyValuesHolder.ofFloat("right", startData.width - startData.paddingRight, endData.width - endData.paddingRight); final PropertyValuesHolder bottomProp = PropertyValuesHolder.ofFloat("bottom", startData.height - startData.paddingBottom, endData.height - endData.paddingBottom); final PropertyValuesHolder fontSizeProp = PropertyValuesHolder.ofFloat("fontSize", startFontSize, endFontSize); final ObjectAnimator animator; if (startData.textColor != endData.textColor) { final PropertyValuesHolder textColorProp = PropertyValuesHolder.ofObject("textColor", new ArgbEvaluator(), startData.textColor, endData.textColor); animator = ObjectAnimator.ofPropertyValuesHolder(drawable, leftProp, topProp, rightProp, bottomProp, fontSizeProp, textColorProp); } else { animator = ObjectAnimator.ofPropertyValuesHolder(drawable, leftProp, topProp, rightProp, bottomProp, fontSizeProp); } final float finalFontSize = endFontSize; AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { textView.getOverlay().remove(drawable); textView.setTextColor(textColors); textView.setHintTextColor(hintColors); textView.setHighlightColor(highlightColor); textView.setLinkTextColor(linkColors); } @Override public void onAnimationPause(Animator animation) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, drawable.getFontSize()); final int paddingLeft = Math.round(drawable.getLeft()); final int paddingTop = Math.round(drawable.getTop()); final float fraction = animator.getAnimatedFraction(); final int paddingRight = Math.round(interpolate(startData.paddingRight, endData.paddingRight, fraction)); final int paddingBottom = Math.round(interpolate(startData.paddingBottom, endData.paddingBottom, fraction)); textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); textView.setTextColor(drawable.getTextColor()); } @Override public void onAnimationResume(Animator animation) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, finalFontSize); textView.setPadding(endData.paddingLeft, endData.paddingTop, endData.paddingRight, endData.paddingBottom); textView.setTextColor(endData.textColor); } }; animator.addListener(listener); animator.addPauseListener(listener); return animator; }
29. RadialTextsView#renderAnimations()
Project: uhabits
File: RadialTextsView.java
File: RadialTextsView.java
/** * Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
30. RadialTextsView#renderAnimations()
Project: NotePad
File: RadialTextsView.java
File: RadialTextsView.java
/** * Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
31. RadialTextsView#renderAnimations()
Project: narrate-android
File: RadialTextsView.java
File: RadialTextsView.java
/** * Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
32. RadialTextsView#renderAnimations()
Project: MaterialDateTimePicker
File: RadialTextsView.java
File: RadialTextsView.java
/** * Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
33. RadialTextsView#renderAnimations()
Project: MaterialDateRangePicker
File: RadialTextsView.java
File: RadialTextsView.java
/** * Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
34. SoftKeyboardView#setMoveSoftKeyAnimation()
Project: Android-tv-widget
File: SoftKeyboardView.java
File: SoftKeyboardView.java
private void setMoveSoftKeyAnimation(SoftKey oldSoftkey, SoftKey targetSoftKey) { PropertyValuesHolder valuesXHolder = PropertyValuesHolder.ofFloat("Left", oldSoftkey.getLeft(), targetSoftKey.getLeft()); PropertyValuesHolder valuesX1Holder = PropertyValuesHolder.ofFloat("Right", oldSoftkey.getRight(), targetSoftKey.getRight()); PropertyValuesHolder valuesYHolder = PropertyValuesHolder.ofFloat("Top", oldSoftkey.getTop(), targetSoftKey.getTop()); PropertyValuesHolder valuesY1Holder = PropertyValuesHolder.ofFloat("Bottom", oldSoftkey.getBottom(), targetSoftKey.getBottom()); // final ObjectAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(targetSoftKey, valuesXHolder, valuesX1Holder, valuesYHolder, valuesY1Holder); scaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float left = (float) animation.getAnimatedValue("Left"); float top = (float) animation.getAnimatedValue("Top"); float right = (float) animation.getAnimatedValue("Right"); float bottom = (float) animation.getAnimatedValue("Bottom"); SoftKey softKey = (SoftKey) scaleAnimator.getTarget(); softKey.setMoveLeft(left); softKey.setMoveTop(top); softKey.setMoveRight(right); softKey.setMoveBottom(bottom); postInvalidate(); } }); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(scaleAnimator); animatorSet.setDuration(mMoveDuration); animatorSet.start(); }
35. SquashAndStretch#animateApi14()
Project: YourAppIdea
File: SquashAndStretch.java
File: SquashAndStretch.java
@TargetApi(14) private void animateApi14(View view, View container, long baseDuration, long animatorScale) { long animationDuration = (long) (baseDuration * animatorScale); // Scale around bottom/middle to simplify squash against the window bottom view.setPivotX(view.getWidth() / 2); view.setPivotY(view.getHeight()); // Animate the button down, accelerating, while also stretching in Y and squashing in X PropertyValuesHolder pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, container.getHeight() - (view.getHeight() + view.getTop() + container.getPaddingTop())); PropertyValuesHolder pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, .7f); PropertyValuesHolder pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.2f); ObjectAnimator downAnim = ObjectAnimator.ofPropertyValuesHolder(view, pvhTY, pvhSX, pvhSY); downAnim.setInterpolator(sAccelerator); downAnim.setDuration((long) (animationDuration * 2)); // Stretch in X, squash in Y, then reverse pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1.5f); pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, .5f); ObjectAnimator stretchAnim = ObjectAnimator.ofPropertyValuesHolder(view, pvhSX, pvhSY); stretchAnim.setRepeatCount(1); stretchAnim.setRepeatMode(ValueAnimator.REVERSE); stretchAnim.setInterpolator(sDecelerator); stretchAnim.setDuration(animationDuration); // Animate back to the start pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0); pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1); pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1); ObjectAnimator upAnim = ObjectAnimator.ofPropertyValuesHolder(view, pvhTY, pvhSX, pvhSY); upAnim.setDuration((long) (animationDuration * 2)); upAnim.setInterpolator(sDecelerator); AnimatorSet set = new AnimatorSet(); set.playSequentially(downAnim, stretchAnim, upAnim); set.start(); }
36. AnimationUtils#tada()
Project: UltimateAndroid
File: AnimationUtils.java
File: AnimationUtils.java
public static ObjectAnimator tada(View view, float shakeFactor) { PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor), Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1000); }
37. AnimationUtils#wholeShake()
Project: UltimateAndroid
File: AnimationUtils.java
File: AnimationUtils.java
/** * Shake the view for whole direction * * @param view * @param shakeFactor * @return */ public static ObjectAnimator wholeShake(View view, float shakeFactor) { PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor), Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1000); }
38. Pop#createAnimator()
Project: sbt-android
File: Pop.java
File: Pop.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f); return new AnimUtils.NoPauseAnimator(ObjectAnimator.ofPropertyValuesHolder(endValues.view, alpha, scaleX, scaleY)); }
39. CustomAnimationActivity#toRightAnimation()
Project: Reachability
File: CustomAnimationActivity.java
File: CustomAnimationActivity.java
private PropertyValuesHolder[] toRightAnimation() { PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("translationX", 0f, getWidth()); PropertyValuesHolder holderR = PropertyValuesHolder.ofFloat("rotation", 0f, 360f); PropertyValuesHolder[] holders = { holderX, holderR }; return holders; }
40. CustomAnimationActivity#fromLeftAnimation()
Project: Reachability
File: CustomAnimationActivity.java
File: CustomAnimationActivity.java
private PropertyValuesHolder[] fromLeftAnimation() { PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("translationX", -getWidth(), 0f); PropertyValuesHolder holderR = PropertyValuesHolder.ofFloat("rotation", 0f, 360f); PropertyValuesHolder[] holders = { holderX, holderR }; return holders; }
41. SubtleAttentionSeeker#tada()
Project: open-keychain
File: SubtleAttentionSeeker.java
File: SubtleAttentionSeeker.java
public static ObjectAnimator tada(View view, float shakeFactor, int duration) { PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor), Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(duration); }
42. SubtleAttentionSeeker#tada()
Project: apg
File: SubtleAttentionSeeker.java
File: SubtleAttentionSeeker.java
public static ObjectAnimator tada(View view, float shakeFactor) { PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor), Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1400); }
43. AniUtils#scaleOut()
Project: WordPress-Android
File: AniUtils.java
File: AniUtils.java
public static void scaleOut(final View target, final int endVisibility, Duration duration, final AnimationEndListener endListener) { if (target == null || duration == null) { return; } PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, scaleX, scaleY); animator.setDuration(duration.toMillis(target.getContext())); animator.setInterpolator(new AccelerateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { target.setVisibility(endVisibility); if (endListener != null) { endListener.onAnimationEnd(); } } }); animator.start(); }
44. PostsListAdapter#animateButtonRows()
Project: WordPress-Android
File: PostsListAdapter.java
File: PostsListAdapter.java
/* * buttons may appear in two rows depending on display size and number of visible * buttons - these rows are toggled through the "more" and "back" buttons - this * routine is used to animate the new row in and the old row out */ private void animateButtonRows(final PostViewHolder holder, final PostsListPost post, final boolean showRow1) { // first animate out the button row, then show/hide the appropriate buttons, // then animate the row layout back in PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f); ObjectAnimator animOut = ObjectAnimator.ofPropertyValuesHolder(holder.layoutButtons, scaleX, scaleY); animOut.setDuration(ROW_ANIM_DURATION); animOut.setInterpolator(new AccelerateInterpolator()); animOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // row 1 holder.btnEdit.setVisibility(showRow1 ? View.VISIBLE : View.GONE); holder.btnView.setVisibility(showRow1 ? View.VISIBLE : View.GONE); holder.btnMore.setVisibility(showRow1 ? View.VISIBLE : View.GONE); // row 2 holder.btnStats.setVisibility(!showRow1 && canShowStatsForPost(post) ? View.VISIBLE : View.GONE); holder.btnPublish.setVisibility(!showRow1 && canPublishPost(post) ? View.VISIBLE : View.GONE); holder.btnTrash.setVisibility(!showRow1 ? View.VISIBLE : View.GONE); holder.btnBack.setVisibility(!showRow1 ? View.VISIBLE : View.GONE); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f); ObjectAnimator animIn = ObjectAnimator.ofPropertyValuesHolder(holder.layoutButtons, scaleX, scaleY); animIn.setDuration(ROW_ANIM_DURATION); animIn.setInterpolator(new DecelerateInterpolator()); animIn.start(); } }); animOut.start(); }
45. WPMainTabLayout#showNoteBadge()
Project: WordPress-Android
File: WPMainTabLayout.java
File: WPMainTabLayout.java
void showNoteBadge(boolean showBadge) { if (mNoteBadge == null) return; boolean isBadged = (mNoteBadge.getVisibility() == View.VISIBLE); if (showBadge == isBadged) { return; } float start = showBadge ? 0f : 1f; float end = showBadge ? 1f : 0f; PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, start, end); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, start, end); ObjectAnimator animScale = ObjectAnimator.ofPropertyValuesHolder(mNoteBadge, scaleX, scaleY); if (showBadge) { animScale.setInterpolator(new BounceInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_longAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mNoteBadge.setVisibility(View.VISIBLE); } }); } else { animScale.setInterpolator(new AccelerateInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mNoteBadge.setVisibility(View.GONE); } }); } animScale.start(); }
46. RadialSelectorView#getReappearAnimator()
Project: uhabits
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
47. RadialSelectorView#getDisappearAnimator()
Project: uhabits
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
48. NormalLineAnimDrawable#getLineAnim()
Project: Spotlight
File: NormalLineAnimDrawable.java
File: NormalLineAnimDrawable.java
private ObjectAnimator getLineAnim() { PropertyValuesHolder pvMoveY = PropertyValuesHolder.ofFloat(FACTOR_Y, 0f, 1f); PropertyValuesHolder pvMoveX = PropertyValuesHolder.ofFloat(FACTOR_X, 0f, 1f); ObjectAnimator lineAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvMoveY, pvMoveX).setDuration(lineAnimDuration); lineAnim.setRepeatMode(ValueAnimator.RESTART); lineAnim.setRepeatCount(mAnimPoints.size() - 1); lineAnim.addUpdateListener(this); if (android.os.Build.VERSION.SDK_INT > 17) { lineAnim.setAutoCancel(true); } lineAnim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { moveTimes = 0; curAnimPoint = mAnimPoints.get(moveTimes); if (mListner != null) mListner.onAnimationStart(animation); } @Override public void onAnimationEnd(Animator animation) { if (mListner != null) mListner.onAnimationEnd(animation); } @Override public void onAnimationCancel(Animator animation) { if (mListner != null) mListner.onAnimationCancel(animation); } @Override public void onAnimationRepeat(Animator animation) { moveTimes++; curAnimPoint = mAnimPoints.get(moveTimes); if (mListner != null) mListner.onAnimationRepeat(animation); } }); //lineAnim.addListener(mListner); return lineAnim; }
49. RadialSelectorView#getReappearAnimator()
Project: NotePad
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
50. RadialSelectorView#getDisappearAnimator()
Project: NotePad
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
51. MovingViewAnimator#createDiagonalAnimator()
Project: NHentai-android
File: MovingViewAnimator.java
File: MovingViewAnimator.java
private ObjectAnimator createDiagonalAnimator(float startW, float endW, float startH, float endH) { float diagonal = Pythagoras(Math.abs(startW - endW), Math.abs(startH - endH)); pathDistances.add(diagonal); PropertyValuesHolder pvhX = createPropertyValuesHolder("scrollX", startW, endW); PropertyValuesHolder pvhY = createPropertyValuesHolder("scrollY", startH, endH); return ObjectAnimator.ofPropertyValuesHolder(mView, pvhX, pvhY); }
52. RadialSelectorView#getReappearAnimator()
Project: narrate-android
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
53. RadialSelectorView#getDisappearAnimator()
Project: narrate-android
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
54. MovingViewAnimator#createDiagonalAnimator()
Project: MovingImageView
File: MovingViewAnimator.java
File: MovingViewAnimator.java
private ObjectAnimator createDiagonalAnimator(float startW, float endW, float startH, float endH) { float diagonal = Pythagoras(Math.abs(startW - endW), Math.abs(startH - endH)); pathDistances.add(diagonal); PropertyValuesHolder pvhX = createPropertyValuesHolder("scrollX", startW, endW); PropertyValuesHolder pvhY = createPropertyValuesHolder("scrollY", startH, endH); return ObjectAnimator.ofPropertyValuesHolder(mView, pvhX, pvhY); }
55. RadialSelectorView#getReappearAnimator()
Project: MaterialDateTimePicker
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
56. RadialSelectorView#getDisappearAnimator()
Project: MaterialDateTimePicker
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
57. RadialSelectorView#getReappearAnimator()
Project: MaterialDateRangePicker
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
58. RadialSelectorView#getDisappearAnimator()
Project: MaterialDateRangePicker
File: RadialSelectorView.java
File: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
59. TypedAction#prepareScaleAnimation()
Project: AndroidAnimationsActions
File: TypedAction.java
File: TypedAction.java
private void prepareScaleAnimation(boolean scaleBy) { float scaleXOffset = scaleBy ? view.getScaleX() : 0; float scaleYOffset = scaleBy ? view.getScaleY() : 0; PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", view.getScaleX(), scaleXOffset + floatTargets[0]); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", view.getScaleY(), scaleYOffset + floatTargets[1]); setValues(scaleX, scaleY); addUpdateListener(new ScaleUpdateListener(view)); }
60. TypedAction#prepareMoveAnimation()
Project: AndroidAnimationsActions
File: TypedAction.java
File: TypedAction.java
private void prepareMoveAnimation(boolean moveBy) { float moveXOffset = moveBy ? view.getX() : 0; float moveYOffset = moveBy ? view.getY() : 0; PropertyValuesHolder x = PropertyValuesHolder.ofFloat("x", view.getX(), moveXOffset + floatTargets[0]); PropertyValuesHolder y = PropertyValuesHolder.ofFloat("y", view.getY(), moveYOffset + floatTargets[1]); setValues(x, y); addUpdateListener(new MoveUpdateListener(view)); }
61. FlipTransitionFactory#getOutAnimator()
Project: android-slideshow-widget
File: FlipTransitionFactory.java
File: FlipTransitionFactory.java
@Override public Animator getOutAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { final PropertyValuesHolder rotation; final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1, 0); switch(axis) { case VERTICAL: target.setRotationX(0); target.setRotationY(0); rotation = PropertyValuesHolder.ofFloat(View.ROTATION_X, 90); break; case HORIZONTAL: default: target.setRotationX(0); target.setRotationY(0); rotation = PropertyValuesHolder.ofFloat(View.ROTATION_Y, 90); break; } ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, rotation); animator.setDuration(getDuration() / 2); animator.setInterpolator(getInterpolator()); return animator; }
62. FlipTransitionFactory#getInAnimator()
Project: android-slideshow-widget
File: FlipTransitionFactory.java
File: FlipTransitionFactory.java
//============================================================================================== // INTERFACE IMPLEMENTATION: SlideTransitionFactory //== @Override public Animator getInAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { target.setAlpha(1); target.setScaleX(1); target.setScaleY(1); target.setTranslationX(0); target.setTranslationY(0); final PropertyValuesHolder rotation; final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0, 1); switch(axis) { case VERTICAL: target.setRotationX(-90); target.setRotationY(0); rotation = PropertyValuesHolder.ofFloat(View.ROTATION_X, 0); break; case HORIZONTAL: default: target.setRotationX(0); target.setRotationY(-90); rotation = PropertyValuesHolder.ofFloat(View.ROTATION_Y, 0); break; } ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, rotation); animator.setDuration(getDuration() / 2); animator.setStartDelay(getDuration() / 2); animator.setInterpolator(getInterpolator()); return animator; }
63. AnimatedLinearLayout#prepareBoundsAnimator()
Project: RxAndroidBootstrap
File: AnimatedLinearLayout.java
File: AnimatedLinearLayout.java
private Animator prepareBoundsAnimator(View child, ChildBounds bounds) { int startLeft = bounds.start.left; int startTop = bounds.start.top; int startRight = bounds.start.right; int startBottom = bounds.start.bottom; int endLeft = bounds.end.left; int endTop = bounds.end.top; int endRight = bounds.end.right; int endBottom = bounds.end.bottom; int changeCount = 0; if (startLeft != endLeft) { child.setLeft(startLeft); changeCount++; } if (startTop != endTop) { child.setTop(startTop); changeCount++; } if (startRight != endRight) { child.setRight(startRight); changeCount++; } if (startBottom != endBottom) { child.setBottom(startBottom); changeCount++; } if (changeCount == 0) { return null; } PropertyValuesHolder pvh[] = new PropertyValuesHolder[changeCount]; int pvhIndex = -1; if (startLeft != endLeft) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("left", startLeft, endLeft); } if (startTop != endTop) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("top", startTop, endTop); } if (startRight != endRight) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("right", startRight, endRight); } if (startBottom != endBottom) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("bottom", startBottom, endBottom); } return ObjectAnimator.ofPropertyValuesHolder(child, pvh); }
64. AnimatedLinearLayout#prepareBoundsAnimator()
Project: MVPAndroidBootstrap
File: AnimatedLinearLayout.java
File: AnimatedLinearLayout.java
private Animator prepareBoundsAnimator(View child, ChildBounds bounds) { int startLeft = bounds.start.left; int startTop = bounds.start.top; int startRight = bounds.start.right; int startBottom = bounds.start.bottom; int endLeft = bounds.end.left; int endTop = bounds.end.top; int endRight = bounds.end.right; int endBottom = bounds.end.bottom; int changeCount = 0; if (startLeft != endLeft) { child.setLeft(startLeft); changeCount++; } if (startTop != endTop) { child.setTop(startTop); changeCount++; } if (startRight != endRight) { child.setRight(startRight); changeCount++; } if (startBottom != endBottom) { child.setBottom(startBottom); changeCount++; } if (changeCount == 0) { return null; } PropertyValuesHolder pvh[] = new PropertyValuesHolder[changeCount]; int pvhIndex = -1; if (startLeft != endLeft) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("left", startLeft, endLeft); } if (startTop != endTop) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("top", startTop, endTop); } if (startRight != endRight) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("right", startRight, endRight); } if (startBottom != endBottom) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("bottom", startBottom, endBottom); } return ObjectAnimator.ofPropertyValuesHolder(child, pvh); }
65. RubberIndicator#move()
Project: AndroidRubberIndicator
File: RubberIndicator.java
File: RubberIndicator.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void move(final boolean toRight) { final int nextPos = getNextPosition(toRight); if (nextPos == -1) return; mSmallCircle = mCircleViews.get(nextPos); // Calculate the new x coordinate for circles. float smallCircleX = toRight ? mLargeCircle.getX() : mLargeCircle.getX() + mLargeCircle.getWidth() - mSmallCircle.getWidth(); float largeCircleX = toRight ? mSmallCircle.getX() + mSmallCircle.getWidth() - mLargeCircle.getWidth() : mSmallCircle.getX(); float outerCircleX = mOuterCircle.getX() + largeCircleX - mLargeCircle.getX(); // animations for large circle and outer circle. PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", mLargeCircle.getX(), largeCircleX); ObjectAnimator largeCircleAnim = ObjectAnimator.ofPropertyValuesHolder(mLargeCircle, pvhX, mPvhScaleX, mPvhScaleY); pvhX = PropertyValuesHolder.ofFloat("x", mOuterCircle.getX(), outerCircleX); ObjectAnimator outerCircleAnim = ObjectAnimator.ofPropertyValuesHolder(mOuterCircle, pvhX, mPvhScaleX, mPvhScaleY); // Animations for small circle PointF smallCircleCenter = mSmallCircle.getCenter(); PointF smallCircleEndCenter = new PointF(smallCircleCenter.x - (mSmallCircle.getX() - smallCircleX), smallCircleCenter.y); // Create motion anim for small circle. mSmallCirclePath.reset(); mSmallCirclePath.moveTo(smallCircleCenter.x, smallCircleCenter.y); mSmallCirclePath.quadTo(smallCircleCenter.x, smallCircleCenter.y, (smallCircleCenter.x + smallCircleEndCenter.x) / 2, (smallCircleCenter.y + smallCircleEndCenter.y) / 2 + mBezierCurveAnchorDistance); mSmallCirclePath.lineTo(smallCircleEndCenter.x, smallCircleEndCenter.y); ValueAnimator smallCircleAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { smallCircleAnim = ObjectAnimator.ofObject(mSmallCircle, "center", null, mSmallCirclePath); } else { final PathMeasure pathMeasure = new PathMeasure(mSmallCirclePath, false); final float[] point = new float[2]; smallCircleAnim = ValueAnimator.ofFloat(0.0f, 1.0f); smallCircleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { pathMeasure.getPosTan(pathMeasure.getLength() * animation.getAnimatedFraction(), point, null); mSmallCircle.setCenter(new PointF(point[0], point[1])); } }); } mPvhRotation.setFloatValues(0, toRight ? -30f : 30f, 0, toRight ? 30f : -30f, 0); ObjectAnimator otherAnim = ObjectAnimator.ofPropertyValuesHolder(mSmallCircle, mPvhRotation, mPvhScale); mAnim = new AnimatorSet(); mAnim.play(smallCircleAnim).with(otherAnim).with(largeCircleAnim).with(outerCircleAnim); mAnim.setInterpolator(new AccelerateDecelerateInterpolator()); mAnim.setDuration(500); mAnim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { swapCircles(mFocusPosition, nextPos); mFocusPosition = nextPos; if (mOnMoveListener != null) { if (toRight) { mOnMoveListener.onMovedToRight(); } else { mOnMoveListener.onMovedToLeft(); } } if (!mPendingAnimations.isEmpty()) { move(mPendingAnimations.removeFirst()); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); mAnim.start(); }