private void SmoothScrollBrowser(bool down) { var delay = (DateTime.Now - scrollLastTime).TotalMilliseconds; if (scrollLastDirection.HasValue && scrollLastDirection == down && SCROLL_ACCEL_DELAY_MS > delay) { scrollAccel += SCROLL_ACCEL_INCREMENT; } else { scrollAccel = 0; } scrollLastTime = DateTime.Now; scrollLastDirection = down; ObjectAnimator anim = ObjectAnimator.OfInt(_browserView, "scrollY", _browserView.ScrollY, _browserView.ScrollY + (down ? 300 + scrollAccel : -300 - scrollAccel)); if (_currentScroll != null) { _currentScroll.End(); anim.SetInterpolator(new DecelerateInterpolator()); } else { anim.SetInterpolator(new AccelerateDecelerateInterpolator()); } anim.SetDuration(500).Start(); _currentScroll = anim; }
public FlippingView(Context context, Listener listener, int width, int height) : base(context) { this.listener = listener; this.flipOutView = new ImageView(context); this.flipInView = new ImageView(context); AddView(flipOutView, width, height); AddView(flipInView, width, height); flipInView.Rotation = -90; ObjectAnimator flipOutAnimator = ObjectAnimator.OfFloat(flipOutView, "rotationY", 0, 90); flipOutAnimator.SetInterpolator(new AccelerateInterpolator()); Animator flipInAnimator = ObjectAnimator.OfFloat(flipInView, "rotationY", -90, 0); flipInAnimator.SetInterpolator(new DecelerateInterpolator()); animations = new AnimatorSet(); animations.PlaySequentially(flipOutAnimator, flipInAnimator); animations.SetDuration(1000); animations.AddListener(new AnimationListener() { AnimationEnd = (animation) => { flipOutView.Rotation = 0; flipInView.Rotation = -90; listener.onFlipped(this); } }); }
private void SmoothScrollBrowser(bool down) { ObjectAnimator anim = ObjectAnimator.OfInt(_browserView, "scrollY", _browserView.ScrollY, _browserView.ScrollY + (down ? 300 : -300)); if (_currentScroll != null) { _currentScroll.End(); anim.SetInterpolator(new DecelerateInterpolator()); } else { anim.SetInterpolator(new AccelerateDecelerateInterpolator()); } anim.SetDuration(500).Start(); _currentScroll = anim; }
ObjectAnimator XAnimator(long duration, EasingFunction easing) { ObjectAnimator animatorX = ObjectAnimator.OfFloat(this, "phaseX", 0f, 1f); animatorX.SetInterpolator(new AnimationInterpolator(easing)); animatorX.SetDuration(duration); return(animatorX); }
private void CreateAnimation() { ObjectAnimator anim = ObjectAnimator.OfInt(pBar, "progress", Element.Minimun, Element.Value); anim.SetDuration(Element.AnimationDuration); anim.SetInterpolator(new DecelerateInterpolator()); anim.Start(); }
private void startActionBarAnimation() { ObjectAnimator actionBarAnimation = ObjectAnimator.OfFloat(_actionBarView, ROTATION, GUILLOTINE_OPENED_ANGLE, ACTION_BAR_ROTATION_ANGLE); actionBarAnimation.SetDuration((long)(_duration * (GuillotineInterpolator.FIRST_BOUNCE_TIME + GuillotineInterpolator.SECOND_BOUNCE_TIME))); actionBarAnimation.SetInterpolator(new ActionBarInterpolator()); actionBarAnimation.Start(); }
public virtual void Show() { ObjectAnimator animator = ObjectAnimator.OfFloat(this, "y", showPosition); animator.SetInterpolator(new BounceInterpolator()); animator.SetDuration(1500); animator.Start(); isShow = true; }
private ObjectAnimator YAnimator(long duration, EasingFunction easing) { ObjectAnimator animatorY = ObjectAnimator.OfFloat(this, "phaseY", 0f, 1f); animatorY.SetInterpolator(new AnimationInterpolator(easing)); animatorY.SetDuration(duration); return(animatorY); }
private void startLightsAnimation() { ObjectAnimator animator = ObjectAnimator.OfFloat(mStartButtonLights, "rotation", 0f, 360f); animator.SetInterpolator(new AccelerateDecelerateInterpolator()); animator.SetDuration(6000); animator.RepeatCount = ValueAnimator.Infinite; mStartButtonLights.SetLayerType(LayerType.Hardware, null); animator.Start(); }
public virtual void Hide() { ObjectAnimator animator = ObjectAnimator.OfFloat(this, "y", hidePosition); animator.SetInterpolator(new BounceInterpolator()); animator.SetDuration(1500); animator.Start(); isShow = false; }
private void Animate(BrinSeekBar v, string val, int i) { if (v.isSeekActive) { return; } ObjectAnimator animation = ObjectAnimator.OfInt(v, val, i); animation.SetDuration(200); // 0.5 second animation.SetInterpolator(new AccelerateDecelerateInterpolator()); animation.Start(); }
private void CreateAnimation() { if (animation == null) { animation = ObjectAnimator.OfFloat(ball, "y", ball.Y, Height - 50f); animation.SetDuration(1500); animation.SetInterpolator(new AccelerateInterpolator(2f)); animation.Update += delegate { Invalidate(); }; } }
public ObjectAnimator StartAnimation(IInterpolator interpolator, long duration, Path path) { // This ObjectAnimator uses the path to change the x and y scale of the view object ObjectAnimator animator = ObjectAnimator.OfFloat(view, "ScaleX", "ScaleY", path); // Set the interpolator and duration for this animation animator.SetDuration(duration); animator.SetInterpolator(interpolator); animator.Start(); return(animator); }
public void AnimateCircular(float toValue, int milliseconds = 500, ITimeInterpolator interpolator = null) { if (animator != null) { animator.Cancel(); } animator = ObjectAnimator.OfFloat(this, "Progress", 0.0f, toValue); if (interpolator != null) { animator.SetInterpolator(interpolator); } animator.SetDuration(milliseconds); animator.RepeatMode = ValueAnimatorRepeatMode.Restart; animator.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //HasOptionsMenu = true; Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); Button botonAnimado = FindViewById <Button>(Resource.Id.botonanimado); botonAnimado.SetWidth(300); ObjectAnimator objectAnimator = ObjectAnimator.OfInt(botonAnimado, "width", 400, 250, 400); objectAnimator.SetDuration(3000); objectAnimator.SetInterpolator(new LinearInterpolator()); objectAnimator.RepeatCount = 100; //objectAnimator.Start(); ObjectAnimator objectAnimator1 = ObjectAnimator.OfInt(botonAnimado, "height", 220, 70, 220); objectAnimator1.SetDuration(3000); objectAnimator1.SetInterpolator(new LinearInterpolator()); objectAnimator1.RepeatCount = 100; ObjectAnimator objectAnimator2 = ObjectAnimator.OfFloat(botonAnimado, "rotationY", 0, 360); objectAnimator2.SetDuration(10000); objectAnimator2.SetInterpolator(new LinearInterpolator()); objectAnimator2.RepeatCount = 100; objectAnimator2.Update += (sender, e) => { if ((float)e.Animation.AnimatedValue >= 90 && (float)e.Animation.AnimatedValue <= 270) { botonAnimado.Text = ""; } else { botonAnimado.Text = "Boton animado"; } }; AnimatorSet ans = new Android.Animation.AnimatorSet(); ans.PlayTogether(objectAnimator, objectAnimator1, objectAnimator2);//,); ans.Start(); //Animator animator = AnimatorInflater.LoadAnimator(this, Resource.Animator.property); //animator.SetTarget(botonAnimado); //animator.Start(); }
public static ValueAnimator Slide(this View view, SlideDirection slideDirection, long duration = DefaultAnimationDuration, ITimeInterpolator interpolator = null) { System.Diagnostics.Debug.WriteLine("Slide Direction: {0}", slideDirection); ObjectAnimator slide = null; switch (slideDirection) { case SlideDirection.FromBottom: slide = ObjectAnimator.OfFloat(view, "translationY", view.MeasuredHeight, 0f); break; case SlideDirection.FromLeft: slide = ObjectAnimator.OfFloat(view, "translationX", -view.MeasuredWidth, 0f); break; case SlideDirection.FromRight: slide = ObjectAnimator.OfFloat(view, "translationX", view.MeasuredWidth, 0f); break; case SlideDirection.FromTop: slide = ObjectAnimator.OfFloat(view, "translationY", -view.MeasuredHeight, 0f); break; case SlideDirection.ToBottom: slide = ObjectAnimator.OfFloat(view, "translationY", 0f, view.MeasuredHeight); break; case SlideDirection.ToLeft: slide = ObjectAnimator.OfFloat(view, "translationX", 0f, -view.MeasuredWidth); break; case SlideDirection.ToRight: slide = ObjectAnimator.OfFloat(view, "translationX", 0f, view.MeasuredWidth); break; case SlideDirection.ToTop: default: slide = ObjectAnimator.OfFloat(view, "translationY", 0f, -view.MeasuredHeight); break; } slide.SetInterpolator(interpolator ?? new DecelerateInterpolator()); slide.SetDuration(duration); slide.Start(); return(slide); }
public async Task <string> ScanAsync() { var scanner = new ZXing.Mobile.MobileBarcodeScanner { UseCustomOverlay = true }; var options = new ZXing.Mobile.MobileBarcodeScanningOptions() { TryHarder = true, AutoRotate = false, UseFrontCameraIfAvailable = false, CameraResolutionSelector = new CameraResolutionSelectorDelegate(SelectLowestResolutionMatchingDisplayAspectRatio), PossibleFormats = new List <ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE } }; View scanView = LayoutInflater.From(Application.Context).Inflate(Resource.Layout.ScanView, null); ImageView imgLine = scanView.FindViewById <ImageView>(Resource.Id.imgLine); ImageView imgClose = scanView.FindViewById <ImageView>(Resource.Id.imgClose); imgClose.Click += delegate { scanner.Cancel(); }; scanner.CustomOverlay = scanView; ObjectAnimator objectAnimator = ObjectAnimator.OfFloat(imgLine, "Y", 0, DpToPixels(240)); objectAnimator.SetDuration(2500); objectAnimator.RepeatCount = -1; objectAnimator.SetInterpolator(new LinearInterpolator()); objectAnimator.RepeatMode = ValueAnimatorRepeatMode.Restart; objectAnimator.Start(); ZXing.Result scanResults = await scanner.Scan(CrossCurrentActivity.Current.Activity, options); if (scanResults != null) { return(scanResults.Text); } return(string.Empty); }
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(); }
private void SetupAnimations() { _objectAnimatorAngle = ObjectAnimator.OfFloat(this, _angleProperty, 360f); _objectAnimatorAngle.SetInterpolator(ANGLE_INTERPOLATOR); _objectAnimatorAngle.SetDuration(ANGLE_ANIMATOR_DURATION); _objectAnimatorAngle.RepeatMode = ValueAnimatorRepeatMode.Restart; _objectAnimatorAngle.RepeatCount = ValueAnimator.Infinite; _objectAnimatorSweep = ObjectAnimator.OfFloat(this, _sweepProperty, 360f - MIN_SWEEP_ANGLE * 2); _objectAnimatorSweep.SetInterpolator(SWEEP_INTERPOLATOR); _objectAnimatorSweep.SetDuration(SWEEP_ANIMATOR_DURATION); _objectAnimatorSweep.RepeatMode = ValueAnimatorRepeatMode.Restart; _objectAnimatorSweep.RepeatCount = ValueAnimator.Infinite; _objectAnimatorSweep.AnimationRepeat += (e, s) => { ToggleAppearingMode(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); Button botonAnimado = FindViewById <Button>(Resource.Id.botonanimado); botonAnimado.SetWidth(300); ObjectAnimator objectAnimator = ObjectAnimator.OfInt(botonAnimado, "width", 300, 250, 300); objectAnimator.SetDuration(3000); objectAnimator.SetInterpolator(new LinearInterpolator()); objectAnimator.RepeatCount = 100; objectAnimator.Start(); }
protected void animateAllAssetsOff(AnimatorListenerAdapter adapter) { // title // 120dp + 50dp + buffer(30dp) ObjectAnimator titleAnimator = ObjectAnimator.OfFloat(mTitle, "translationY", GameUtility.Px(-200)); titleAnimator.SetInterpolator(new AccelerateInterpolator(2)); titleAnimator.SetDuration(300); // lights ObjectAnimator lightsAnimatorX = ObjectAnimator.OfFloat(mStartButtonLights, "scaleX", 0f); ObjectAnimator lightsAnimatorY = ObjectAnimator.OfFloat(mStartButtonLights, "scaleY", 0f); // tooltip ObjectAnimator tooltipAnimator = ObjectAnimator.OfFloat(mTooltip, "alpha", 0f); tooltipAnimator.SetDuration(100); // settings button ObjectAnimator settingsAnimator = ObjectAnimator.OfFloat(mSettingsGameButton, "translationY", GameUtility.Px(120)); settingsAnimator.SetInterpolator(new AccelerateInterpolator(2)); settingsAnimator.SetDuration(300); // google play button ObjectAnimator googlePlayAnimator = ObjectAnimator.OfFloat(mGooglePlayGameButton, "translationY", GameUtility.Px(120)); googlePlayAnimator.SetInterpolator(new AccelerateInterpolator(2)); googlePlayAnimator.SetDuration(300); // start button ObjectAnimator startButtonAnimator = ObjectAnimator.OfFloat(mStartGameButton, "translationY", GameUtility.Px(130)); startButtonAnimator.SetInterpolator(new AccelerateInterpolator(2)); startButtonAnimator.SetDuration(300); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(titleAnimator, lightsAnimatorX, lightsAnimatorY, tooltipAnimator, settingsAnimator, googlePlayAnimator, startButtonAnimator); animatorSet.AddListener(adapter); animatorSet.Start(); }
private ObjectAnimator buildOpeningAnimation() { ObjectAnimator rotationAnimator = initAnimator(ObjectAnimator.OfFloat(_guillotineView, ROTATION, GUILLOTINE_CLOSED_ANGLE, GUILLOTINE_OPENED_ANGLE)); rotationAnimator.SetInterpolator(_interpolator); rotationAnimator.SetDuration(_duration); rotationAnimator.AnimationStart += delegate { _guillotineView.Visibility = ViewStates.Visible; _isOpening = true; }; rotationAnimator.AnimationEnd += delegate { _isOpening = false; if (_listner != null) { _listner.OnGuillotineOpened(); } }; return(rotationAnimator); }
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(); }
private void startTootipAnimation() { ObjectAnimator scaleY = ObjectAnimator.OfFloat(mTooltip, "scaleY", 0.8f); scaleY.SetDuration(200); ObjectAnimator scaleYBack = ObjectAnimator.OfFloat(mTooltip, "scaleY", 1f); scaleYBack.SetDuration(500); scaleYBack.SetInterpolator(new BounceInterpolator()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.StartDelay = 1000; animatorSet.PlaySequentially(scaleY, scaleYBack); animatorSet.AnimationEnd += (sender, e) => { animatorSet.StartDelay = 2000; animatorSet.Start(); }; mTooltip.SetLayerType(LayerType.Hardware, null); animatorSet.Start(); }
public bool OnTouch(View v, MotionEvent e) { switch (e.Action) { case MotionEventActions.Down: ObjectAnimator upAnim = ObjectAnimator.OfFloat(v, "translationZ", 0); upAnim.SetDuration(200); upAnim.SetInterpolator(new DecelerateInterpolator()); upAnim.Start(); break; case MotionEventActions.Up: case MotionEventActions.Cancel: ObjectAnimator downAnim = ObjectAnimator.OfFloat(v, "translationZ", 20); downAnim.SetDuration(200); downAnim.SetInterpolator(new AccelerateInterpolator()); downAnim.Start(); break; } return(false); }
public static ValueAnimator Spin(this View view, SpinDirection spinDirection = SpinDirection.Clockwise, long duration = DefaultAnimationDuration, ITimeInterpolator interpolator = null) { ObjectAnimator rotation = ObjectAnimator.OfFloat(view, "rotation", 0, 360); switch (spinDirection) { case SpinDirection.Clockwise: rotation = ObjectAnimator.OfFloat(view, "rotation", 0, 360); break; case SpinDirection.CounterClockwise: rotation = ObjectAnimator.OfFloat(view, "rotation", 0, -360); break; } rotation.SetDuration(duration); rotation.SetInterpolator(interpolator ?? new LinearInterpolator()); rotation.RepeatCount = ValueAnimator.Infinite; rotation.Start(); return(rotation); }
/** * change the image with a fade * @param drawable * @param fadeDuration */ public static void SetImageDrawable(ImageView imageView, Drawable drawable, int fadeDuration) { float alpha = ViewHelper.GetAlpha(imageView); ImageView viewToAnimate = imageView; //fade to alpha=0 ObjectAnimator fadeOut = ObjectAnimator.OfFloat(viewToAnimate, "alpha", 0); fadeOut.SetDuration(fadeDuration); fadeOut.SetInterpolator(new DecelerateInterpolator()); fadeOut.AnimationEnd += (sender, args) => { //change the image when alpha=0 imageView.SetImageDrawable(drawable); //then fade to alpha=1 ObjectAnimator fadeIn = ObjectAnimator.OfFloat(viewToAnimate, "alpha", alpha); fadeIn.SetDuration(fadeDuration); fadeIn.SetInterpolator(new AccelerateInterpolator()); fadeIn.Start(); }; fadeOut.Start(); }
private void addTile(int id, ViewGroup parent) { TileView tileView = TileView.fromXml(Application.Context, parent); tileView.LayoutParameters = mTileLayoutParams; parent.AddView(tileView); parent.SetClipChildren(false); mViewReference.Add(id, tileView); tileView.setTileImage(mBoardArrangment.getTileBitmap(id, mSize)); tileView.Click += (sender, e) => { if (!mLocked && tileView.isFlippedDown()) { tileView.flipUp(); flippedUp.Add(id); if (flippedUp.Count == 2) { mLocked = true; } Shared.EventBus.Notify(new FlipCardEvent(id)); } }; ObjectAnimator scaleXAnimator = ObjectAnimator.OfFloat(tileView, "scaleX", 0.8f, 1f); scaleXAnimator.SetInterpolator(new BounceInterpolator()); ObjectAnimator scaleYAnimator = ObjectAnimator.OfFloat(tileView, "scaleY", 0.8f, 1f); scaleYAnimator.SetInterpolator(new BounceInterpolator()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(scaleXAnimator, scaleYAnimator); animatorSet.SetDuration(500); tileView.SetLayerType(LayerType.Hardware, null); animatorSet.Start(); }
/** * change the image with a fade * @param urlImage * @param fadeDuration * * TODO : remove Picasso */ public static void SetImageUrl(ImageView imageView, string urlImage, int fadeDuration) { float alpha = ViewHelper.GetAlpha(imageView); ImageView viewToAnimate = imageView; //fade to alpha=0 ObjectAnimator fadeOut = ObjectAnimator.OfFloat(viewToAnimate, "alpha", 0); fadeOut.SetDuration(fadeDuration); fadeOut.SetInterpolator(new DecelerateInterpolator()); fadeOut.AnimationEnd += (sender, args) => { //change the image when alpha=0 Picasso.With(imageView.Context).Load(urlImage).CenterCrop().Fit().Into(viewToAnimate, () => { //then fade to alpha=1 ObjectAnimator fadeIn = ObjectAnimator.OfFloat(viewToAnimate, "alpha", alpha); fadeIn.SetDuration(fadeDuration); fadeIn.SetInterpolator(new AccelerateInterpolator()); fadeIn.Start(); }, () => { }); }; fadeOut.Start(); }
/** * Manage animation for Android < KITKAT * * @param child */ private void ensureOrCancelObjectAnimation(T child, int offset, bool withAnimation) { if (translationObjectAnimator != null) { translationObjectAnimator.Cancel(); } translationObjectAnimator = ObjectAnimator.OfFloat(child, /*View.TRANSLATION_Y*/ "translationY", offset); translationObjectAnimator.SetDuration(withAnimation ? ANIM_DURATION : 0); translationObjectAnimator.SetInterpolator(INTERPOLATOR); translationObjectAnimator.AddUpdateListener( new CustomViewPropertyIAnimatorUpdateListener((animation) => { if (snackbarLayout != null && snackbarLayout.LayoutParameters is ViewGroup.MarginLayoutParams) { targetOffset = child.MeasuredHeight - child.TranslationY; ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)snackbarLayout.LayoutParameters; p.SetMargins(p.LeftMargin, p.TopMargin, p.RightMargin, (int)targetOffset); snackbarLayout.RequestLayout(); } // Animate Floating Action Button if (floatingActionButton != null && floatingActionButton.LayoutParameters is ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)floatingActionButton.LayoutParameters; fabTargetOffset = fabDefaultBottomMargin - child.TranslationY + snackBarY; p.SetMargins(p.LeftMargin, p.TopMargin, p.RightMargin, (int)fabTargetOffset); floatingActionButton.RequestLayout(); } // Pass navigation height to listener if (navigationPositionListener != null) { navigationPositionListener.onPositionChange((int)(child.MeasuredHeight - child.TranslationY + snackBarY)); } }) ); }