List of usage examples for android.animation ObjectAnimator ofPropertyValuesHolder
@NonNull public static ObjectAnimator ofPropertyValuesHolder(Object target, PropertyValuesHolder... values)
PropertyValueHolder
objects. From source file:Main.java
public static Animator animSlideIn(int i1, View view) { float af[] = new float[2]; af[0] = i1;/*w w w .j av a2s. c o m*/ af[1] = 0.0F; return ObjectAnimator.ofPropertyValuesHolder(view, new PropertyValuesHolder[] { PropertyValuesHolder.ofFloat("translationY", af), PropertyValuesHolder.ofFloat("alpha", new float[] { 0.3F, 1.0F }) }); }
From source file:Main.java
public static Animator animSlideOut(int i1, View view) { float af[] = new float[2]; af[0] = 0.0F;// w w w. j av a 2s. c o m af[1] = -i1; return ObjectAnimator.ofPropertyValuesHolder(view, new PropertyValuesHolder[] { PropertyValuesHolder.ofFloat("translationY", af), PropertyValuesHolder.ofFloat("alpha", new float[] { 0.7F, 0.0F }) }); }
From source file:Main.java
public static ObjectAnimator alphaIn(View view) { PropertyValuesHolder pvhAlpha = PropertyValuesHolder.ofKeyframe(View.ALPHA, Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(1f, 1f));//from www . j a va 2 s .c o m return ObjectAnimator.ofPropertyValuesHolder(view, pvhAlpha).setDuration(300); }
From source file:Main.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); }
From source file:Main.java
/** * Shake the view from left to right/*from w w w .java 2s .c o m*/ * * @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); }
From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java
private Animator createCollapsingAnimator(ArrowItemViewHolder newHolder, long duration) { if (arrow != null) { arrow.setVisibility(View.INVISIBLE); }/*from w ww . j a v a 2s . c o m*/ final View oldView = itemView; final View newView = newHolder.itemView; final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(oldView, PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 255, 0)); backgroundAnimator.setDuration(duration); final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(oldView, oldView, newView); boundsAnimator.setDuration(duration); boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(backgroundAnimator, boundsAnimator); return animatorSet; }
From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java
private Animator createExpandingAnimator(ArrowItemViewHolder oldHolder, long duration) { final View oldView = oldHolder.itemView; final View newView = itemView; final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(newView, oldView, newView); boundsAnimator.setDuration(duration); boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(newView, PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 0, 255)); backgroundAnimator.setDuration(duration); 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);/*ww w. j av a2 s . c o m*/ arrowAnimation.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); animatorSet = new AnimatorSet(); animatorSet.playTogether(backgroundAnimator, boundsAnimator, arrowAnimation); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { AnimatorUtils.startDrawableAnimation(arrow); } }); } else { animatorSet = new AnimatorSet(); animatorSet.playTogether(backgroundAnimator, boundsAnimator); } return animatorSet; }
From source file:com.taobao.weex.dom.action.AnimationAction.java
private @Nullable ObjectAnimator createAnimator(final View target, final int viewPortWidth) { if (target == null) { return null; }//ww w .j av a2 s . c o m WXAnimationBean.Style style = mAnimationBean.styles; if (style != null) { ObjectAnimator animator; List<PropertyValuesHolder> holders = style.getHolders(); if (!TextUtils.isEmpty(style.backgroundColor)) { BorderDrawable borderDrawable; if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) { holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor))); } else if (target.getBackground() instanceof ColorDrawable) { holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(), WXResourceUtils.getColor(style.backgroundColor))); } } if (style.getPivot() != null) { Pair<Float, Float> pair = style.getPivot(); target.setPivotX(pair.first); target.setPivotY(pair.second); } animator = ObjectAnimator.ofPropertyValuesHolder(target, holders.toArray(new PropertyValuesHolder[holders.size()])); animator.setStartDelay(mAnimationBean.delay); if (target.getLayoutParams() != null && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) { DimensionUpdateListener listener = new DimensionUpdateListener(target); ViewGroup.LayoutParams layoutParams = target.getLayoutParams(); if (!TextUtils.isEmpty(style.width)) { listener.setWidth(layoutParams.width, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth)); } if (!TextUtils.isEmpty(style.height)) { listener.setHeight(layoutParams.height, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth)); } animator.addUpdateListener(listener); } return animator; } else { return null; } }
From source file:com.taobao.weex.ui.action.GraphicActionAnimation.java
private @Nullable ObjectAnimator createAnimator(final View target, final int viewPortWidth) { if (target == null) { return null; }//from ww w . jav a 2 s.c o m WXAnimationBean.Style style = mAnimationBean.styles; if (style != null) { ObjectAnimator animator; List<PropertyValuesHolder> holders = style.getHolders(); if (!TextUtils.isEmpty(style.backgroundColor)) { BorderDrawable borderDrawable; if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) { holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor))); } else if (target.getBackground() instanceof ColorDrawable) { holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(), WXResourceUtils.getColor(style.backgroundColor))); } } if (target.getLayoutParams() != null && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) { ViewGroup.LayoutParams layoutParams = target.getLayoutParams(); if (!TextUtils.isEmpty(style.width)) { holders.add(PropertyValuesHolder.ofInt(new WidthProperty(), layoutParams.width, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth))); } if (!TextUtils.isEmpty(style.height)) { holders.add(PropertyValuesHolder.ofInt(new HeightProperty(), layoutParams.height, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth))); } } if (style.getPivot() != null) { Pair<Float, Float> pair = style.getPivot(); target.setPivotX(pair.first); target.setPivotY(pair.second); } animator = ObjectAnimator.ofPropertyValuesHolder(target, holders.toArray(new PropertyValuesHolder[holders.size()])); animator.setStartDelay(mAnimationBean.delay); return animator; } else { return null; } }
From source file:com.itsronald.widget.IndicatorDotPathView.java
/** * Animation: fill out the connecting center dot path to form a straight path between the two * dots./*from www .java2 s . co m*/ * * @return An animator that grows pathCenter to the appropriate height. */ @NonNull private Animator centerSegmentGrowAnimator() { final float fromScale = 0f, toScale = 1f; final ObjectAnimator growAnimator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { final PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, fromScale, toScale); growAnimator = ObjectAnimator.ofPropertyValuesHolder(centerSegment, scaleYProperty); } else { growAnimator = ObjectAnimator.ofFloat(centerSegment, "scaleY", fromScale, toScale); } // Start growing when the two ends of the path meet in the middle. final long animationDuration = PATH_STRETCH_ANIM_DURATION / 4; growAnimator.setStartDelay(animationDuration); growAnimator.setDuration(animationDuration); growAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); centerSegment.setVisibility(VISIBLE); } }); return growAnimator; }