protected override void OnFinishInflate() { base.OnFinishInflate(); label = FindViewById<TextView>(Resource.Id.Label); circle = FindViewById<CircledImageView>(Resource.Id.Circle); expandCircleRadius = circle.CircleRadius; shrinkCircleRadius = expandCircleRadius * ShrinkCricleRatio; shrinkCircleAnimator = ObjectAnimator.OfFloat(circle, "circleRadius", expandCircleRadius, shrinkCircleRadius); shrinkLabelAnimator = ObjectAnimator.OfFloat(label, "alpha", ExpandLabelAlpha, ShrinkLabelAlpha); // FIXME Xamarin: new AnimatorSet().SetDuration(long) should return an AnimatorSet shrinkAnimator = new AnimatorSet(); shrinkAnimator.SetDuration(AnimationDurationMs); shrinkAnimator.PlayTogether(shrinkCircleAnimator, shrinkLabelAnimator); expandCircleAnimator = ObjectAnimator.OfFloat(circle, "circleRadius", shrinkCircleRadius, expandCircleRadius); expandLabelAnimator = ObjectAnimator.OfFloat(label, "alpha", ShrinkLabelAlpha, ExpandLabelAlpha); expandAnimator = new AnimatorSet(); expandAnimator.SetDuration(AnimationDurationMs); expandAnimator.PlayTogether(expandCircleAnimator, expandLabelAnimator); }
private AnimatorSet buildMenuAnimation(View target, float alpha) { AnimatorSet alphaAnimation = new AnimatorSet(); alphaAnimation.PlayTogether( ObjectAnimator.OfFloat(target, "alpha", alpha) ); alphaAnimation.SetDuration(250); return alphaAnimation; }
/** * A helper method to build scale up animation; * * @param target * @param targetScaleX * @param targetScaleY * @return */ private AnimatorSet buildScaleUpAnimation(View target, float targetScaleX, float targetScaleY) { AnimatorSet scaleUp = new AnimatorSet(); scaleUp.PlayTogether( ObjectAnimator.OfFloat(target, "scaleX", targetScaleX), ObjectAnimator.OfFloat(target, "scaleY", targetScaleY) ); if (mUse3D) { scaleUp.PlayTogether(ObjectAnimator.OfFloat(target, "rotationY", 0)); } scaleUp.SetDuration(250); return scaleUp; }
private Animator.IAnimatorListener animationListener;//=new AnimationListenerClass(this); //private Animator.AnimatorListener animationListener = new Animator.AnimatorListener() { // @Override // public void onAnimationStart(Animator animation) { // if (isOpened()){ // showScrollViewMenu(scrollViewMenu); // if (menuListener != null) // menuListener.openMenu(); // } // } // @Override // public void onAnimationEnd(Animator animation) { // // reset the view; // if(isOpened()){ // viewActivity.setTouchDisable(true); // viewActivity.setOnClickListener(viewActivityOnClickListener); // }else{ // viewActivity.setTouchDisable(false); // viewActivity.setOnClickListener(null); // hideScrollViewMenu(scrollViewLeftMenu); // hideScrollViewMenu(scrollViewRightMenu); // if (menuListener != null) // menuListener.closeMenu(); // } // } // @Override // public void onAnimationCancel(Animator animation) { // } // @Override // public void onAnimationRepeat(Animator animation) { // } //}; /** * A helper method to build scale down animation; * * @param target * @param targetScaleX * @param targetScaleY * @return */ private AnimatorSet buildScaleDownAnimation(View target, float targetScaleX, float targetScaleY) { AnimatorSet scaleDown = new AnimatorSet(); scaleDown.PlayTogether( ObjectAnimator.OfFloat(target, "scaleX", targetScaleX), ObjectAnimator.OfFloat(target, "scaleY", targetScaleY) ); if (mUse3D) { int angle = scaleDirection == DIRECTION_LEFT ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE; scaleDown.PlayTogether(ObjectAnimator.OfFloat(target, "rotationY", angle)); } scaleDown.SetInterpolator(AnimationUtils.LoadInterpolator(activity, Android.Resource.Animation.DecelerateInterpolator)); scaleDown.SetDuration(250); return scaleDown; }
private AnimatorSet GetAnimatorSet(int idx, bool expand) { AnimatorSet set = null; var avgRadians = this.ToRadians(360 / (this.ChildCount - 1)); var w = Math.Min(this.MeasuredWidth, this.MeasuredHeight) / 2; var cx = this.MeasuredWidth / 2; var cy = this.MeasuredHeight / 2; var c = this.GetChildAt(idx); var radians = idx * avgRadians; var hw = c.MeasuredWidth / 2; var hy = c.MeasuredHeight / 2; var tmp = (w - hw); var l = w + (int)Math.Round(tmp * Math.Cos(radians) - hw); var t = w + (int)Math.Round(tmp * Math.Sin(radians) - hw); var duration = new Random(1000).Next(200, 1000); set = new AnimatorSet(); set.SetInterpolator(new Android.Views.Animations.BounceInterpolator()); set.SetTarget(c); set.SetDuration(200 * idx + duration); //set.SetDuration(200); float[] xs = new float[] { cx - hw, l }; float[] ys = new float[] { cy - hy, t }; float[] ss = new float[] { 0.1f, 1 }; if (!expand) { Array.Reverse(xs); Array.Reverse(ys); Array.Reverse(ss); } var aniX = ObjectAnimator.OfFloat(c, "X", xs); var aniY = ObjectAnimator.OfFloat(c, "Y", ys); var aniSX = ObjectAnimator.OfFloat(c, "ScaleX", ss); var aniSY = ObjectAnimator.OfFloat(c, "ScaleY", ss); aniX.SetAutoCancel(true); aniY.SetAutoCancel(true); aniSX.SetAutoCancel(true); aniSY.SetAutoCancel(true); set.PlayTogether(aniX, aniY, aniSX, aniSY); set.AnimationEnd += Set_AnimationEnd; return set; }
public void UpThrow() { ObjectAnimator objectAnimator = ObjectAnimator.OfFloat(shapeLoadingView, "translationY", mDistance, 0); ObjectAnimator scaleIndication = ObjectAnimator.OfFloat(indicationIm, "scaleX", 0.2f, 1); ObjectAnimator objectAnimator1 = null; switch(shapeLoadingView.GetShape()) { case ShapeLoadingView.Shape.RECT: { objectAnimator1 = ObjectAnimator.OfFloat(shapeLoadingView, "rotation", 0, -120); } break; case ShapeLoadingView.Shape.CIRCLE: { objectAnimator1 = ObjectAnimator.OfFloat(shapeLoadingView, "rotation", 0, 180); } break; case ShapeLoadingView.Shape.TRIANGLE: { objectAnimator1 = ObjectAnimator.OfFloat(shapeLoadingView, "rotation", 0, 180); } break; } objectAnimator.SetDuration(ANIMATION_DURATION); objectAnimator1.SetDuration(ANIMATION_DURATION); objectAnimator.SetInterpolator(new DecelerateInterpolator()); objectAnimator1.SetInterpolator(new DecelerateInterpolator()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.SetDuration(ANIMATION_DURATION); animatorSet.PlayTogether(objectAnimator, objectAnimator1, scaleIndication); animatorSet.AnimationEnd += (e, s) => { FreeFall(); }; animatorSet.Start(); }
public ColorItem(Context context) : base(context) { View.Inflate (context, Resource.Layout.ColorPickerItem, this); label = FindViewById<TextView> (Resource.Id.Label); colorView = FindViewById<CircledImageView> (Resource.Id.Color); expandCircleRadius = colorView.CircleRadius; shrinkCircleRadius = expandCircleRadius * ShrinkCricleRatio; shrinkCircleAnimator = ObjectAnimator.OfFloat (colorView, "circleRadius", expandCircleRadius, shrinkCircleRadius); shrinkLabelAnimator = ObjectAnimator.OfFloat (label, "alpha", ExpandLabelAlpha, ShrinkLabelAlpha); // FIXME Xamarin: new AnimatorSet().SetDuration(long) should return an AnimatorSet shrinkAnimator = new AnimatorSet (); shrinkAnimator.SetDuration (AnimationDurationMs); shrinkAnimator.PlayTogether (shrinkCircleAnimator, shrinkLabelAnimator); expandCircleAnimator = ObjectAnimator.OfFloat (colorView, "circleRadius", shrinkCircleRadius, expandCircleRadius); expandLabelAnimator = ObjectAnimator.OfFloat (label, "alpha", ShrinkLabelAlpha, ExpandLabelAlpha); expandAnimator = new AnimatorSet (); expandAnimator.SetDuration (AnimationDurationMs); expandAnimator.PlayTogether (expandCircleAnimator, expandLabelAnimator); }
public void AnimateXAndWidth (Frame newFrame, Action completed) { ObjectAnimator xAnim = ObjectAnimator.OfFloat (this, LEFT_MARGIN, (float)Frame.X, (float)newFrame.X); ObjectAnimator wAnim = ObjectAnimator.OfInt (this, NEW_WIDTH, Frame.W, newFrame.W); AnimatorSet set = new AnimatorSet (); set.SetDuration (FRAMEANIMATIONTIME); set.PlayTogether (new ObjectAnimator[] { xAnim, wAnim }); set.Start (); set.AnimationEnd += delegate { completed (); }; }
/** * Flings given {@link android.view.View} out of sight. * * @param view the parent {@link android.view.View}. * @param position the position of the item in the {@link android.widget.ListAdapter} corresponding to the {@code View}. * @param flingToRight {@code true} if the {@code View} should be flinged to the right, {@code false} if it should be flinged to the left. */ private void flingView(View view, int position, bool flingToRight) { if (mViewWidth < 2) { mViewWidth = mListViewWrapper.getListView().Width; } View swipeView = getSwipeView(view); ObjectAnimator xAnimator = ObjectAnimator.OfFloat(swipeView, TRANSLATION_X, flingToRight ? mViewWidth : -mViewWidth); ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(swipeView, ALPHA, 0); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(xAnimator, alphaAnimator); animatorSet.SetDuration(mAnimationTime); animatorSet.AddListener(new FlingAnimatorListener(view, position,this)); animatorSet.Start(); }
public ExpandHelper(Context context, Callback callback, int small, int large) { this.smallSize = small; this.maximumStretch = Math.Max (smallSize, 1) * StretchInterval; this.largeSize = large; this.context = context; this.callback = callback; this.scaler = new ViewScaler(); this.gravity = GravityFlags.Top; //this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f); this.scaleAnimation = ValueAnimator.OfFloat (0f); this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue; this.scaleAnimation.SetDuration (ExpandDuration); AnimatorListenerAdapter glowVisibilityController = new AnimatorListener (); glowTopAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f); glowTopAnimation.AddListener (glowVisibilityController); glowBottomAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f); glowBottomAnimation.AddListener (glowVisibilityController); glowAnimationSet = new AnimatorSet(); glowAnimationSet.Play (glowTopAnimation).With(glowBottomAnimation); glowAnimationSet.SetDuration(GlowDuration); detector = new DoubleSwipeDetector(context, new GestureDetector (this)); }
/// <summary> /// Builds the AnimatorSet that will create the expanding animation - the user will perceive the thumbnail getting bigger. /// </summary> /// <param name="expandedView">This is the ImageView that the thumbnail will scale up to.</param> /// <param name="startBounds">The visible rectangle of the thumbnail (global coordinates).</param> /// <param name="finalBounds">The visible rectangle of the full sized image (global coordinates).</param> /// <param name="startScale"></param> /// <returns></returns> private AnimatorSet BuildExpandingAnimatorSet(ImageView expandedView, Rect startBounds, Rect finalBounds, float startScale) { // Each expanding animator is unique to the start location - we'll cache the AnimatorSet // instance based on the starting location. int key = startBounds.GetHashCode (); if (_expandingAnimators.ContainsKey(key)) { return _expandingAnimators[key]; } AnimatorSet expandSet = new AnimatorSet(); expandSet.Play(ObjectAnimator.OfFloat(expandedView, View.X, startBounds.Left, finalBounds.Left)) .With(ObjectAnimator.OfFloat(expandedView, View.Y, startBounds.Top, finalBounds.Top)) .With(ObjectAnimator.OfFloat(expandedView, "ScaleX", startScale, 1f)) .With(ObjectAnimator.OfFloat(expandedView, "ScaleY", startScale, 1f)); expandSet.SetDuration(_shortAnimationDuration); expandSet.SetInterpolator(new DecelerateInterpolator()); expandSet.AnimationEnd += NullOutCurrentAnimator; expandSet.AnimationCancel += NullOutCurrentAnimator; _expandingAnimators.Add(key, expandSet); return expandSet; }
/// <summary> /// Builds the AnimatorSet to shrink the full sized image back to the thumbnail. /// </summary> /// <param name="bigView">The full sized view.</param> /// <param name="thumbView">The thumbnail view.</param> /// <param name="startBounds">The visible rectangle of the thumbnail when it is visible.</param> /// <param name="scale">Scale ratio.</param> /// <returns></returns> private AnimatorSet BuildShrinkingAnimatorSet(View bigView, View thumbView, Rect startBounds, float scale) { if (_shrinkingAnimators.ContainsKey(thumbView.Id)) { return _shrinkingAnimators[thumbView.Id]; } AnimatorSet shrinkSet = new AnimatorSet(); shrinkSet.Play(ObjectAnimator.OfFloat(bigView, View.X, startBounds.Left)) .With(ObjectAnimator.OfFloat(bigView, View.Y, startBounds.Top)) .With(ObjectAnimator.OfFloat(bigView, "ScaleX", scale)) .With(ObjectAnimator.OfFloat(bigView, "ScaleY", scale)); shrinkSet.SetDuration(_shortAnimationDuration); shrinkSet.SetInterpolator(new DecelerateInterpolator()); shrinkSet.AnimationEnd += (sender1, args1) =>{ thumbView.Alpha = 1.0f; bigView.Visibility = ViewStates.Gone; NullOutCurrentAnimator(sender1, args1); }; shrinkSet.AnimationCancel += (sender1, args1) =>{ thumbView.Alpha = 1.0f; bigView.Visibility = ViewStates.Gone; NullOutCurrentAnimator(sender1, args1); }; _shrinkingAnimators.Add(thumbView.Id, shrinkSet); return shrinkSet; }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated (view, savedInstanceState); var interpolator = new Android.Views.Animations.AccelerateDecelerateInterpolator (); var xDelta = 12.ToPixels (); var yDelta = 8.ToPixels (); var transX = ObjectAnimator.OfFloat (logoImage, "translationX", -xDelta, xDelta); var transY = ObjectAnimator.OfFloat (logoImage, "translationY", -yDelta, 0, -yDelta); var rot = ObjectAnimator.OfFloat (logoImage, "rotation", -1.2f, 1.2f); // Ad infinitam transX.RepeatCount = transY.RepeatCount = rot.RepeatCount = -1; transX.RepeatMode = transY.RepeatMode = rot.RepeatMode = ValueAnimatorRepeatMode.Reverse; logoAnimation = new AnimatorSet (); logoAnimation.PlayTogether (transX, transY, rot); logoAnimation.SetDuration (800); logoAnimation.SetInterpolator (interpolator); logoAnimation.Start (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); mBlurringView = FindViewById<BlurringView> (Resource.Id.blurring_view); View blurredView = FindViewById(Resource.Id.blurred_view); mBlurringView.SetBlurredView (blurredView); mImageViews [0] = FindViewById<ImageView> (Resource.Id.image0); mImageViews [1] = FindViewById<ImageView> (Resource.Id.image1); mImageViews [2] = FindViewById<ImageView> (Resource.Id.image2); mImageViews [3] = FindViewById<ImageView> (Resource.Id.image3); mImageViews [4] = FindViewById<ImageView> (Resource.Id.image4); mImageViews [5] = FindViewById<ImageView> (Resource.Id.image5); mImageViews [6] = FindViewById<ImageView> (Resource.Id.image6); mImageViews [7] = FindViewById<ImageView> (Resource.Id.image7); mImageViews [8] = FindViewById<ImageView> (Resource.Id.image8); // Get our button from the layout resource, // and attach an event to it Button shuffleButton = FindViewById<Button> (Resource.Id.shuffle_button); Button shiftButton = FindViewById<Button> (Resource.Id.shift_button); shiftButton.Click += (sender, e) => { if (!mShifted) { foreach (ImageView imageView in mImageViews) { ObjectAnimator tx = ObjectAnimator.OfFloat (imageView, "translationX", (float)((mRandom.NextDouble () - 0.5f) * 500)); tx.Update += (s, ea) => mBlurringView.Invalidate(); ObjectAnimator ty = ObjectAnimator.OfFloat (imageView, "translationY", (float)((mRandom.NextDouble () - 0.5f) * 500)); tx.Update += (s, ea) => mBlurringView.Invalidate(); AnimatorSet set = new AnimatorSet(); set.PlayTogether(tx, ty); set.SetDuration(3000); set.SetInterpolator(new OvershootInterpolator()); set.AnimationStart += (s, ea) => imageView.SetLayerType(LayerType.Hardware, null); set.AnimationEnd += (s, ea) => imageView.SetLayerType(LayerType.None, null); set.AnimationCancel += (s, ea) => imageView.SetLayerType (LayerType.None, null); set.Start(); } mShifted = true; } else { foreach (ImageView imageView in mImageViews) { ObjectAnimator tx = ObjectAnimator.OfFloat (imageView, "translationX", 0); tx.Update += (s, ea) => mBlurringView.Invalidate(); ObjectAnimator ty = ObjectAnimator.OfFloat (imageView, "translationY", 0); tx.Update += (s, ea) => mBlurringView.Invalidate(); AnimatorSet set = new AnimatorSet(); set.PlayTogether(tx, ty); set.SetDuration(3000); set.SetInterpolator(new OvershootInterpolator()); // set.AddListener(new AnimationEndListener(imageView)); set.AnimationStart += (s, ea) => imageView.SetLayerType(LayerType.Hardware, null); set.AnimationEnd += (s, ea) => imageView.SetLayerType(LayerType.None, null); set.AnimationCancel += (s, ea) => imageView.SetLayerType (LayerType.None, null); set.Start(); } mShifted = false; } }; shuffleButton.Click += (sender, e) => { int newStartIndex; do { newStartIndex = mImageIds[mRandom.Next(mImageIds.Length)]; } while (newStartIndex == mStartIndex); mStartIndex = newStartIndex; for (int i = 0; i < mImageViews.Length; i++) { int drawableId = mImageIds[(mStartIndex +i) % mImageIds.Length]; mImageViews[i].SetImageDrawable(ApplicationContext.Resources.GetDrawable(drawableId)); } mBlurringView.Invalidate(); }; }
/** * Animates given View. * * @param view the View that should be animated. */ private void animateView(int position, View view, Animator[] animators) { if (mAnimationStartMillis == -1) { mAnimationStartMillis = SystemClock.UptimeMillis(); } // ViewHelper.setAlpha(view, 0); view.Alpha = 0; AnimatorSet set = new AnimatorSet(); set.PlayTogether(animators); set.StartDelay = calculateAnimationDelay(position); set.SetDuration(mAnimationDurationMillis); set.Start(); mAnimators.Put(view.GetHashCode(), set); }
private void PlayAnimation() { var animator = ObjectAnimator.OfFloat (this, "animationSeek", 0.0f, 1.0f); var animatorSet = new AnimatorSet (); animatorSet.SetDuration (AnimationDuration); animatorSet.SetInterpolator (new DecelerateInterpolator ()); animatorSet.SetTarget (this); animatorSet.Play(animator); animatorSet.Start(); }
private static IntPtr n_SetDuration_J(IntPtr jnienv, IntPtr native__this, long duration) { AnimatorSet @object = Java.Lang.Object.GetObject <AnimatorSet> (native__this, JniHandleOwnership.DoNotTransfer) !; return(JNIEnv.ToJniHandle(@object.SetDuration(duration))); }
/** * Animates the pending {@link android.view.View} back to its original position. */ private void restoreCurrentViewTranslation() { if (mCurrentView == null) { return; } ObjectAnimator xAnimator = ObjectAnimator.OfFloat(mSwipingView, TRANSLATION_X, 0); ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(mSwipingView, ALPHA, 1); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(xAnimator, alphaAnimator); animatorSet.SetDuration(mAnimationTime); animatorSet.AddListener(new RestoreAnimatorListener(mCurrentView, mCurrentPosition,this)); animatorSet.Start(); }
public void shift(View view) { if (!mShifted) { foreach (ImageView imageView in mImageViews) { ObjectAnimator tx = ObjectAnimator.OfFloat(imageView, View.X, (mRandom.NextFloat() - 0.5f) * 500); tx.AddUpdateListener(new AnimListener(mBlurringView)); ObjectAnimator ty = ObjectAnimator.OfFloat(imageView, View.Y, (mRandom.NextFloat() - 0.5f) * 500); ty.AddUpdateListener(new AnimListener(mBlurringView)); AnimatorSet set = new AnimatorSet(); set.PlayTogether(tx, ty); set.SetDuration(3000); set.SetInterpolator(new OvershootInterpolator()); set.AddListener(new AnimationEndListener(imageView)); set.Start(); }; mShifted = true; } else { foreach (ImageView imageView in mImageViews) { ObjectAnimator tx = ObjectAnimator.OfFloat(imageView, View.X, 0); tx.AddUpdateListener(new AnimListener(mBlurringView)); ObjectAnimator ty = ObjectAnimator.OfFloat(imageView, View.Y, 0); ty.AddUpdateListener(new AnimListener(mBlurringView)); AnimatorSet set = new AnimatorSet(); set.PlayTogether(tx, ty); set.SetDuration(3000); set.SetInterpolator(new OvershootInterpolator()); set.AddListener(new AnimationEndListener(imageView)); set.Start(); }; mShifted = false; } }
public void FreeFall() { ObjectAnimator objectAnimator = ObjectAnimator.OfFloat(shapeLoadingView, "translationY", 0, mDistance); ObjectAnimator scaleIndication = ObjectAnimator.OfFloat(indicationIm, "scaleX", 1, 0.2f); objectAnimator.SetDuration(ANIMATION_DURATION); objectAnimator.SetInterpolator(new AccelerateInterpolator()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.SetDuration(ANIMATION_DURATION); animatorSet.PlayTogether(objectAnimator, scaleIndication); animatorSet.AnimationEnd += (e, s) => { shapeLoadingView.ChangeShape(); UpThrow(); }; animatorSet.Start(); }