List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> property, float... values)
From source file:com.caij.codehub.ui.transitions.MorphDialogToFab.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*w w w.j a v a 2s. com*/ public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator(AnimUtils.getMaterialInterpolator(sceneRoot.getContext())); return transition; }
From source file:com.josecalles.porridge.transitions.MorphDialogToFab.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {//www .j a va2 s . com Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator( AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); return transition; }
From source file:com.caij.codehub.ui.transitions.MorphFabToDialog.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w ww . j a v a 2 s.c om public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // ease in the dialog's child views (slide up & fade in) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; float offset = vg.getHeight() / 3; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.setTranslationY(offset); v.setAlpha(0f); v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator( AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in)); offset *= 1.8f; } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator( AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); return transition; }
From source file:com.example.linhdq.test.install.InstallActivity.java
private void startInstallAnimation() { mTip1.setAlpha(0);/*from w w w. ja v a2s.c o m*/ mTip2.setAlpha(0); mTip3.setAlpha(0); mYoutube.setAlpha(0); ObjectAnimator anim1 = ObjectAnimator.ofFloat(mTip1, "alpha", 1); ObjectAnimator anim2 = ObjectAnimator.ofFloat(mTip2, "alpha", 1); ObjectAnimator anim3 = ObjectAnimator.ofFloat(mTip3, "alpha", 1); ObjectAnimator anim4 = ObjectAnimator.ofFloat(mYoutube, "alpha", 1); AnimatorSet set = new AnimatorSet(); set.setStartDelay(300); set.setDuration(600); set.playTogether(anim1, anim2, anim3, anim4); set.start(); mFairyAnimation.start(); }
From source file:com.softminds.matrixcalculator.base_activities.faqs.java
@Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20); animator.setDuration(200);/* ww w . j a v a 2 s. c o m*/ animator.setInterpolator(new DecelerateInterpolator()); animator.start(); view.performClick(); return true; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationZ", 0); animator2.setDuration(200); animator2.setInterpolator(new AccelerateInterpolator()); animator2.start(); return true; default: return false; } }
From source file:com.amitupadhyay.aboutexample.ui.transitions.MorphDialogToFab.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {//from w w w.j a va 2 s . co m Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(getFastOutLinearInInterpolator(vg.getContext())).start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator(getFastOutSlowInInterpolator(sceneRoot.getContext())); return transition; }
From source file:com.josecalles.porridge.transitions.MorphFabToDialog.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; }//w w w . ja v a2 s .c o m Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // ease in the dialog's child views (slide up & fade in) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; float offset = vg.getHeight() / 3; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.setTranslationY(offset); v.setAlpha(0f); v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator( AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in)); offset *= 1.8f; } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator( AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); return transition; }
From source file:android.support.transition.Fade.java
/** * Utility method to handle creating and running the Animator. *//*from ww w. j a v a2 s . c o m*/ private Animator createAnimation(final View view, float startAlpha, float endAlpha) { if (startAlpha == endAlpha) { return null; } ViewUtils.setTransitionAlpha(view, startAlpha); final ObjectAnimator anim = ObjectAnimator.ofFloat(view, ViewUtils.TRANSITION_ALPHA, endAlpha); if (DBG) { Log.d(LOG_TAG, "Created animator " + anim); } FadeAnimatorListener listener = new FadeAnimatorListener(view); anim.addListener(listener); addListener(new TransitionListenerAdapter() { @Override public void onTransitionEnd(@NonNull Transition transition) { ViewUtils.setTransitionAlpha(view, 1); ViewUtils.clearNonTransitionAlpha(view); transition.removeListener(this); } }); return anim; }
From source file:im.ene.ribbon.FixedActionTabView.java
@Override protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) { if (!animate) { updateLayoutOnAnimation(1, expanded); setIconTranslation(expanded ? 0 : (paddingTopInactive - paddingTopActive)); return;//from ww w .j ava2s . co m } final AnimatorSet set = new AnimatorSet(); set.setDuration(animationDuration); set.setInterpolator(interpolator); final ValueAnimator textScaleAnimator = ObjectAnimator.ofFloat(this, "textScale", expanded ? TEXT_SCALE_ACTIVE : 1); textScaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { final float fraction = animation.getAnimatedFraction(); updateLayoutOnAnimation(fraction, expanded); } }); final ValueAnimator iconTranslationAnimator = ObjectAnimator.ofFloat(this, "iconTranslation", expanded ? 0 : (paddingTopInactive - paddingTopActive)); set.playTogether(textScaleAnimator, iconTranslationAnimator); set.start(); }
From source file:com.sysdata.widget.accordion.CollapsedViewHolder.java
private Animator createCollapsingAnimator(ArrowItemViewHolder oldHolder, long duration) { final View oldView = oldHolder.itemView; final View newView = itemView; final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(newView, oldView, newView) .setDuration(duration);/* ww w .j a v a 2 s . co m*/ boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); final AnimatorSet animatorSet; if (arrow != null) { final View oldArrow = oldHolder.arrow; final Rect oldArrowRect = new Rect(0, 0, oldArrow.getWidth(), oldArrow.getHeight()); final Rect newArrowRect = new Rect(0, 0, arrow.getWidth(), arrow.getHeight()); ((ViewGroup) newView).offsetDescendantRectToMyCoords(arrow, newArrowRect); ((ViewGroup) oldView).offsetDescendantRectToMyCoords(oldArrow, oldArrowRect); final float arrowTranslationY = oldArrowRect.bottom - newArrowRect.bottom; arrow.setTranslationY(arrowTranslationY); arrow.setVisibility(View.VISIBLE); final Animator arrowAnimation = ObjectAnimator.ofFloat(arrow, View.TRANSLATION_Y, 0f) .setDuration(duration); arrowAnimation.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); animatorSet = new AnimatorSet(); animatorSet.playTogether(boundsAnimator, arrowAnimation); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { AnimatorUtils.startDrawableAnimation(arrow); } }); } else { animatorSet = new AnimatorSet(); animatorSet.playTogether(boundsAnimator); } return animatorSet; }