示例#1
0
        public void SetCompletionRatioAnimated(double ratio)
        {
            if (wavy == null)
            {
                return;
            }

            var level     = ComputeLevel(ratio);
            var currLevel = ComputeLevel(currentRatio);

            if (ratio <= currentRatio)
            {
                wavy.SetWavyLevel(level);
            }
            else
            {
                wavy.MaxWavyLevel = level;
                var animator = ObjectAnimator.OfInt(wavy, "alpha", currLevel, level);
                animator.SetDuration(4000);
                animator.AnimationEnd += (sender, e) => {
                    var a = (ObjectAnimator)sender;
                    a.RemoveAllListeners();
                    var w = (WaveDrawable)a.Target;
                    wavy.BubblesEnabled = false;
                };
                animator.SetInterpolator(new Android.Views.Animations.DecelerateInterpolator());
                animator.Start();
                wavy.BubblesEnabled = true;
            }
            currentRatio = ratio;
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.RequestWindowFeature(WindowFeatures.NoTitle);
            this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)
                                                       (SystemUiFlags.LayoutStable
                                                        | SystemUiFlags.LayoutHideNavigation
                                                        | SystemUiFlags.LayoutFullscreen
                                                        | SystemUiFlags.HideNavigation
                                                        | SystemUiFlags.Fullscreen
                                                        | SystemUiFlags.Immersive);

            SetContentView(Resource.Layout.combat);

            textAlarm            = FindViewById <TextView>(Resource.Id.combat_txt_viev);
            DialogQuestions.mode = DialogQuestions.combat;
            var textColorAnim = ObjectAnimator.OfInt(textAlarm, "textColor", Color.Black, Color.Transparent);

            textColorAnim.SetDuration(500);
            textColorAnim.SetEvaluator(new ArgbEvaluator());
            textColorAnim.RepeatCount = ValueAnimator.Infinite;
            textColorAnim.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
            textColorAnim.Start();
            textAlarm.SetTypeface(Typeface.CreateFromAsset(Assets, "h.otf"), TypefaceStyle.Normal);
            textAlarm.Click += delegate
            {
                Finish();
            };
        }
示例#3
0
        /**
         * Toogle the play/pause status
         *
         * @param withAnim false to change status without animation
         */
        public void Toggle(bool withAnim)
        {
            if (withAnim)
            {
                if (mAnimatorSet != null)
                {
                    mAnimatorSet.Cancel();
                }

                mAnimatorSet = new AnimatorSet();
                bool           isPlay    = mDrawable.IsPlay();
                ObjectAnimator colorAnim = ObjectAnimator.OfInt(this, "color", isPlay ? mPauseBackgroundColor : mPlayBackgroundColor);
                colorAnim.SetEvaluator(new ArgbEvaluator());
                Animator pausePlayAnim = mDrawable.GetPausePlayAnimator();
                mAnimatorSet.SetInterpolator(new DecelerateInterpolator());
                mAnimatorSet.SetDuration(PlayPauseAnimationDuration);
                mAnimatorSet.PlayTogether(colorAnim, pausePlayAnim);
                mAnimatorSet.Start();
            }
            else
            {
                bool isPlay = mDrawable.IsPlay();
                InitStatus(!isPlay);
                Invalidate();
            }
        }
        private void ShowHelp(object sender, EventArgs e)
        {
            if (solver == null)
            {
                return;
            }

            List <SolutionMove> solution = solver.get_solution();

            if (solution.Count > 0)
            {
                SolutionMove hintMove = solution[0];
                int          node_id  = board[hintMove.move_y][hintMove.move_x] + 1;

                // find the correct textTile and make it blink
                TextTileView textTile = (TextTileView)tilesArray[Array.IndexOf(coordsArray, node_id)];

                ValueAnimator colorAnim = ObjectAnimator.OfInt(textTile, "BackgroundColor", Color.DarkGreen, Color.Green);
                colorAnim.SetDuration(350);
                colorAnim.SetEvaluator(new ArgbEvaluator());
                colorAnim.RepeatCount = 2;
                colorAnim.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
                colorAnim.Start();
            }
        }
示例#5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            SetContentView(Resource.Layout.MyThirdLayout);

            var button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += (sender, e) => {
                Finish(); // back to the previous activity
            };

            var parentLayout = FindViewById <LinearLayout>(Resource.Id.parentLayout);


            ValueAnimator _openingBackgroundAnimation;

            var colorStart1 = Color.Transparent;
            var colorEnd1   = Color.Red;

            _openingBackgroundAnimation = ObjectAnimator.OfInt(
                parentLayout, "BackgroundColor", colorStart1,
                colorEnd1);
            _openingBackgroundAnimation.SetDuration(2000);
            _openingBackgroundAnimation.SetEvaluator(new ArgbEvaluator());
            _openingBackgroundAnimation.RepeatCount = 0;

            _openingBackgroundAnimation.Start();
        }
        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;
        }
        private void StartAnimation()
        {
            var sunYStart = _sunView.Top;
            var sunYEnd   = _skyView.Height;

            var heightAnimator = ObjectAnimator
                                 .OfFloat(_sunView, "y", sunYStart, sunYEnd)
                                 .SetDuration(3000);

            heightAnimator.SetInterpolator(new AccelerateInterpolator());

            var sunsetSkyAnimator = ObjectAnimator
                                    .OfInt(_skyView, "backgroundColor", _blueSkyColor, _sunsetSkyColor)
                                    .SetDuration(3000) as ObjectAnimator;

            sunsetSkyAnimator.SetEvaluator(new ArgbEvaluator());

            var nightSkyAnimator = ObjectAnimator
                                   .OfInt(_skyView, "backgroundColor", _sunsetSkyColor, _nightSkyColor)
                                   .SetDuration(1500) as ObjectAnimator;

            nightSkyAnimator.SetEvaluator(new ArgbEvaluator());

            var animatorSet = new AnimatorSet();

            animatorSet
            .Play(heightAnimator)
            .With(sunsetSkyAnimator)
            .Before(nightSkyAnimator);
            animatorSet.Start();
        }
        public async void OnGlobalLayout()
        {
            productImage.ViewTreeObserver.RemoveGlobalOnLayoutListener(this);

            const int DeltaX = 100;

            var img1 = Images.FromUrl(Product.ImageForSize(images [0], Images.ScreenWidth));
            var img2 = Images.FromUrl(Product.ImageForSize(images [1], Images.ScreenWidth));

            productDrawable              = new KenBurnsDrawable(Color.DarkBlue);
            productDrawable.FirstBitmap  = await img1;
            productDrawable.SecondBitmap = await img2;
            productImage.SetImageDrawable(productDrawable);
            currentIndex++;

            var evaluator   = new MatrixEvaluator();
            var finalMatrix = new Matrix();

            finalMatrix.SetTranslate(-DeltaX, -(float)productDrawable.FirstBitmap.Height / 1.3f + (float)productImage.Height);
            finalMatrix.PostScale(1.27f, 1.27f);
            kenBurnsMovement         = ValueAnimator.OfObject(evaluator, new Matrix(), finalMatrix);
            kenBurnsMovement.Update += (sender, e) => productDrawable.SetMatrix((Matrix)e.Animation.AnimatedValue);
            kenBurnsMovement.SetDuration(14000);
            kenBurnsMovement.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
            kenBurnsMovement.RepeatCount = ValueAnimator.Infinite;
            kenBurnsMovement.Start();

            kenBurnsAlpha = ObjectAnimator.OfInt(productDrawable, "alpha", 0, 0, 0, 255, 255, 255);
            kenBurnsAlpha.SetDuration(kenBurnsMovement.Duration);
            kenBurnsAlpha.RepeatMode       = ValueAnimatorRepeatMode.Reverse;
            kenBurnsAlpha.RepeatCount      = ValueAnimator.Infinite;
            kenBurnsAlpha.AnimationRepeat += (sender, e) => NextImage();
            kenBurnsAlpha.Start();
        }
示例#9
0
        private void UpdateCode()
        {
            var code = _generator.Compute();

            var spacesInserted = 0;
            var groupSize      = Math.Min(MaxCodeGroupSize, _digits / 2);

            for (var i = 0; i < _digits; ++i)
            {
                if (i % groupSize == 0 && i > 0)
                {
                    code = code.Insert(i + spacesInserted, " ");
                    spacesInserted++;
                }
            }

            _codeTextView.Text = code;

            _secondsRemaining = _period - (int)DateTimeOffset.Now.ToUnixTimeSeconds() % _period;
            var progress = (int)Math.Floor((double)_progressBar.Max * _secondsRemaining / _period);

            _progressBar.Progress = progress;

            var animator = ObjectAnimator.OfInt(_progressBar, "progress", 0);

            animator.SetDuration(_secondsRemaining * 1000);
            animator.SetInterpolator(new LinearInterpolator());
            animator.Start();
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                _textColorChangingAnimation = ObjectAnimator.OfInt(this.Control, "textColor",
                                                                   Color.Red.ToAndroid(), Color.Blue.ToAndroid());
                _textColorChangingAnimation.SetDuration(1000);
                _textColorChangingAnimation.SetEvaluator(new ArgbEvaluator());
                _textColorChangingAnimation.RepeatCount = ValueAnimator.Infinite;
                _textColorChangingAnimation.RepeatMode  = ValueAnimatorRepeatMode.Reverse;

                ((AnimatingTextColorButton)e.NewElement).PropertyChanged += AnimatingTextColorButton_PropertyChanged;

                if (((AnimatingTextColorButton)e.NewElement).IsTextColorAnimating)
                {
                    StartTextColorAnimation();
                }
            }

            if (e.OldElement != null)
            {
                ((AnimatingTextColorButton)e.OldElement).PropertyChanged -= AnimatingTextColorButton_PropertyChanged;
            }
        }
示例#11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.RequestWindowFeature(WindowFeatures.NoTitle);
            this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)
                                                       (SystemUiFlags.LayoutStable
                                                        | SystemUiFlags.LayoutHideNavigation
                                                        | SystemUiFlags.LayoutFullscreen
                                                        | SystemUiFlags.HideNavigation
                                                        | SystemUiFlags.Fullscreen
                                                        | SystemUiFlags.Immersive);

            SetContentView(Resource.Layout.damage);
            DialogQuestions.mode = DialogQuestions.damage;
            textDamage           = FindViewById <TextView>(Resource.Id.blink_txt_damage);
            textDamage.SetTypeface(Typeface.CreateFromAsset(Assets, "h.otf"), TypefaceStyle.Normal);
            textDamage.Click += delegate { Finish(); };
            var textColorAnim = ObjectAnimator.OfInt(textDamage, "textColor", Color.Red, Color.Transparent);

            textColorAnim.SetDuration(500);
            textColorAnim.SetEvaluator(new ArgbEvaluator());
            textColorAnim.RepeatCount = ValueAnimator.Infinite;
            textColorAnim.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
            textColorAnim.Start();
            FindViewById <LinearLayout>(Resource.Id.damage_LO).Click += delegate
            {
                Finish();
                DialogQuestions.mode = DialogQuestions.dialog;
                DialogQuestions.mqttClient.Publish("nautilus/room3_cabin/tablet/mode", Encoding.UTF8.GetBytes(DialogQuestions.mode), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true);
                Intent intent = new Intent(this, typeof(MainActivity));
                intent.AddFlags(ActivityFlags.SingleTop);
                StartActivity(intent);
            };

            new Task(() =>
            {
                while (true)
                {
                    try
                    {
                        if (textDamage.Visibility == ViewStates.Gone)
                        {
                            RunOnUiThread(() => textDamage.Visibility = ViewStates.Visible);
                        }
                        else
                        {
                            RunOnUiThread(() => textDamage.Visibility = ViewStates.Gone);
                        }
                    }
                    catch
                    {
                    }

                    Thread.Sleep(700);
                }
            });
        }
示例#12
0
        private void CreateAnimation()
        {
            ObjectAnimator anim = ObjectAnimator.OfInt(pBar, "progress", Element.Minimun, Element.Value);

            anim.SetDuration(Element.AnimationDuration);
            anim.SetInterpolator(new DecelerateInterpolator());
            anim.Start();
        }
        public static ViewPropertyAnimator ScrollY(this ViewPropertyAnimator vpa, ImageView imgView, params int[] values)
        {
            ObjectAnimator objAnim = ObjectAnimator.OfInt(imgView, "ScrollY", values);

            objAnim.SetDuration(vpa.Duration);
            objAnim.StartDelay = vpa.StartDelay;
            objAnim.Start();
            return(vpa);
        }
        private void Answer_Click(object sender, EventArgs e)
        {
            TransitionManager.BeginDelayedTransition((ViewGroup)rootView,
                                                     new ChangeText().SetChangeBehavior(ChangeText.ChangeBehaviorOutIn));

            FButton btn = sender as FButton;

            if (btn.Text.Equals(correctAnswer.ToString()))
            {
                numberOfCorrectAnswers++;

                int colorFrom = Resources.GetColor(Resource.Color.transparent);
                int colorTo   = Resources.GetColor(Resource.Color.fbutton_color_green_sea);

                ValueAnimator colorAnim = ObjectAnimator.OfInt(questionLayout, "backgroundColor", (int)colorFrom, (int)colorTo);
                colorAnim.SetDuration(500);
                colorAnim.SetEvaluator(new ArgbEvaluator());
                colorAnim.RepeatCount = 1;
                colorAnim.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
                colorAnim.Start();
            }
            else
            {
                int colorFrom = Resources.GetColor(Resource.Color.transparent);
                int colorTo   = Resources.GetColor(Android.Resource.Color.HoloRedDark);

                ValueAnimator colorAnim = ObjectAnimator.OfInt(questionLayout, "backgroundColor", (int)colorFrom, (int)colorTo);
                colorAnim.SetDuration(500);
                colorAnim.SetEvaluator(new ArgbEvaluator());
                colorAnim.RepeatCount = 1;
                colorAnim.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
                colorAnim.Start();
            }

            if (question == 10)
            {
                timer.Stop();

                startLayout.Visibility       = ViewStates.Visible;
                igrajPonovoLayout.Visibility = ViewStates.Visible;
                brojTacnihNaKraju.Text       = numberOfCorrectAnswers.ToString();
                vremeNaKraju.Text            = vremeResavanja.ToString();

                CRecord record = new CRecord();
                record.GameId = App.MathWithAnswersCode + (int)operacija;
                record.Result = numberOfCorrectAnswers;
                record.Time   = vremeResavanja;
                App.db.InsertRecord(record);
                return;
            }

            SetValues();
            question++;

            redniBrojZadatka.Text = question.ToString();
            tacnihOdgovoraTW.Text = numberOfCorrectAnswers.ToString();
        }
        public static ViewPropertyAnimator ScrollX(this ViewPropertyAnimator vpa, ImageView imgView, params int[] values)
        {
            ObjectAnimator objAnim = ObjectAnimator.OfInt(imgView, "ScrollX", values);

            objAnim.SetDuration(vpa.Duration / 2); //Divide by 2 so it will take less time.
            objAnim.StartDelay = vpa.StartDelay;
            objAnim.Start();
            return(vpa);
        }
        public void AnimateTargetToPoint(MaterialShowcaseView showcaseView, Point point)
        {
            var set       = new AnimatorSet();
            var xAnimator = ObjectAnimator.OfInt(showcaseView, "showcaseX", point.X);
            var yAnimator = ObjectAnimator.OfInt(showcaseView, "showcaseY", point.Y);

            set.PlayTogether(xAnimator, yAnimator);
            set.SetInterpolator(_interpolator);
            set.Start();
        }
示例#17
0
        public void ScrollTo(int targetX, int targetY, int duration = 500)
        {
            //https://stackoverflow.com/questions/8642677/reduce-speed-of-smooth-scroll-in-scroll-view/33013806
            //TODO : android animation is weird

            var animator = ObjectAnimator.OfInt(target: _scrollView, propertyName: "scrollX", values: targetX);

            animator.SetDuration(duration);
            animator.Start();
        }
示例#18
0
        void OnSeekBarStopTrackingTouch(object sender, SeekBar.StopTrackingTouchEventArgs e)
        {
            var seekBar   = (SeekBar)sender;
            var toValue   = seekBar.Progress;
            var fromValue = this._seekBar2.Progress;

            var objAnim = ObjectAnimator.OfInt(this._seekBar2, "Progress", fromValue, toValue);

            objAnim.SetDuration(1000);
            objAnim.Start();
        }
示例#19
0
        public void OpenMenu()
        {
            if (!IsOpened)
            {
                _menuButton.Enabled = false;
                _menuButton.Animate()
                .Rotation(135.0f)
                .SetDuration(ANIMATION_DURATION)
                .Start();

                var backgroundAnimation = ObjectAnimator.OfInt(this, "backgroundColor", unchecked ((int)0x00000000), unchecked ((int)0xA0000000));
                backgroundAnimation.SetEvaluator(new ArgbEvaluator());
                backgroundAnimation.SetDuration(ANIMATION_DURATION)
                .Start();

                int delay = 0;

                var children = (OpenDirection == OPEN_DOWN || OpenDirection == OPEN_RIGHT) ? _originalChildren : _originalChildren.AsEnumerable().Reverse().ToList();
                for (var i = 0; i < children.Count; i++)
                {
                    var child = children[i];
                    child.Visibility = ViewStates.Visible;

                    var animation = child.Animate()
                                    .ScaleX(1.0f)
                                    .ScaleY(1.0f)
                                    .SetDuration(ANIMATION_DURATION)
                                    .SetStartDelay(delay);

                    if (i == children.Count - 1)
                    {
                        animation = animation.WithEndAction(new Runnable(() => _menuButton.Enabled = true));
                    }

                    animation.Start();

                    if (child.GetTag(Resource.Id.fab_label) is TextView label)
                    {
                        label.Visibility = ViewStates.Visible;
                        label.Animate()
                        .Alpha(1.0f)
                        .TranslationX(0.0f)
                        .SetDuration(ANIMATION_DURATION)
                        .SetStartDelay(delay)
                        .Start();
                    }

                    delay += ANIMATION_DELAY;
                }
            }

            IsOpened = true;
        }
        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();
        }
示例#21
0
        public void Dismiss()
        {
            if (IsShown)
            {
                IsShown    = false;
                Visibility = ViewStates.Invisible;

                var backgroundAnimation = ObjectAnimator.OfInt(this, "backgroundColor", unchecked ((int)0xA0000000), unchecked ((int)0x00000000));
                backgroundAnimation.SetEvaluator(new ArgbEvaluator());
                backgroundAnimation.SetDuration(ANIMATION_DURATION)
                .Start();
            }
        }
示例#22
0
 void HideSwipeDown()
 {
     ActionBar.Show();
     swipeText.Visibility = ViewStates.Invisible;
     bar1Fade             = ObjectAnimator.OfInt(bar1, "progress", bar1.Progress, 0);
     bar1Fade.SetDuration(250);
     bar1Fade.Start();
     bar2Fade = ObjectAnimator.OfInt(bar2, "progress", bar2.Progress, 0);
     bar2Fade.SetDuration(250);
     bar2Fade.Start();
     bar2Fade.AnimationEnd += (sender, e) => loadingBars.Visibility = ViewStates.Gone;
     setup = false;
 }
示例#23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ValueAnimator);

            var seekBar = FindViewById <SeekBar>(Resource.Id.SeekBarValueAnimator);

            ValueAnimator colorAnim = ObjectAnimator.OfInt(seekBar, "progress", 0, 100);

            colorAnim.SetDuration(1000);
            colorAnim.Start();
        }
示例#24
0
        private void CreateWarningAnimation()
        {
            // Create animation.
            int fromColor = DefaultColor.ToArgb();
            int toColor   = WarningColor.ToArgb();

            _warningAnimation = ObjectAnimator.OfInt(_remainingView, "backgroundColor", fromColor, toColor);
            _warningAnimation.SetEvaluator(new ArgbEvaluator());
            _warningAnimation.SetInterpolator(new LinearInterpolator());
            _warningAnimation.SetDuration(250);
            _warningAnimation.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
            _warningAnimation.RepeatCount = -1;              //infinite
        }
示例#25
0
            private static void WonAnimation(Java.Lang.Object value)
            {
                cntRepeat = 0;
                ObjectAnimator colorAnim = ObjectAnimator.OfInt(value, "textColor", Color.White, Color.Transparent);

                colorAnim.SetDuration(800);
                colorAnim.SetEvaluator(new ArgbEvaluator());
                colorAnim.RepeatCount = 3;
                colorAnim.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
                colorAnim.Start();
                BlockButton();
                colorAnim.AnimationEnd += ColorAnim_AnimationEnd;
            }
示例#26
0
        protected override void OnAttached()
        {
            var radius = 100;// Math.Max(this.Container.Width, this.Container.Height);

            this.Drb = new RippleDrawable(this.Container.Background);
            this.Container.Background = this.Drb;

            this.Container.Touch += Container_Touch;

            this.Anim         = ObjectAnimator.OfInt(1, radius);
            this.Anim.Update += (s, arg) => this.Drb.Radius = (int)arg.Animation.AnimatedValue;
            this.Anim.SetInterpolator(new AccelerateDecelerateInterpolator());
            this.Anim.SetDuration(300);
        }
示例#27
0
        public void CloseMenu()
        {
            if (IsOpened)
            {
                _menuButton.Enabled = false;
                _menuButton.StartAnimation(AnimationUtils.LoadAnimation(Context, Resource.Animation.fab_close));

                var backgroundAnimation = ObjectAnimator.OfInt(this, "backgroundColor", unchecked ((int)0xA0000000), unchecked ((int)0x00000000));
                backgroundAnimation.SetEvaluator(new ArgbEvaluator());
                backgroundAnimation.SetDuration(ANIMATION_DURATION)
                .Start();

                int delay = 0;

                var children = (OpenDirection == OPEN_DOWN || OpenDirection == OPEN_RIGHT) ? _originalChildren.AsEnumerable().Reverse().ToList() : _originalChildren;
                for (var i = 0; i < children.Count; i++)
                {
                    var child = children[i];

                    var childAnim = AnimationUtils.LoadAnimation(Context, Resource.Animation.child_shrink);
                    childAnim.AnimationEnd += (s, e) => child.Visibility = ViewStates.Gone;
                    if (i == children.Count - 1)
                    {
                        childAnim.AnimationEnd += (s, e) =>
                        {
                            _menuButton.Enabled = true;
                            IsOpened            = false;
                        };
                    }
                    child.PostDelayed(() => child.StartAnimation(childAnim), delay);

                    if (child.GetTag(Resource.Id.fab_label) is TextView label)
                    {
                        var layoutParameters = child.LayoutParameters as LayoutParams;

                        var labelAnim = GetCloseLabelAnimation(layoutParameters.LabelDirection);
                        labelAnim.AnimationEnd += (s, e) => label.Visibility = ViewStates.Gone;
                        label.PostDelayed(() =>
                        {
                            label.Visibility = ViewStates.Visible;
                            label.StartAnimation(labelAnim);
                        }, delay);
                    }

                    delay += ANIMATION_DELAY;
                }
            }
        }
示例#28
0
        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();
        }
示例#29
0
        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;
        }
示例#30
0
        public override bool OnTouchEvent(MotionEvent e)
        {
            switch (e.Action)
            {
            case MotionEventActions.Down:
                _startX = this.ScrollX;
                this.Parent.RequestDisallowInterceptTouchEvent(true);
                break;

            case MotionEventActions.Move:
                this.Parent.RequestDisallowInterceptTouchEvent(false);
                break;

            case MotionEventActions.Up:
                _endX = this.ScrollX;
                float fullWidth = Resources.DisplayMetrics.WidthPixels;
                //ToDo: Trying to animate the scroller by assigning new position after user leave the tap
                //need to calculate the exact position of the scroller on screen and calculte
                if (_endX > (_startX + (fullWidth / 2)))
                {                         // going right to left
                    _startPage = _pagesStartAt.FirstOrDefault(x => x == _startX);
                    //Console.WriteLine ("Move Forward to next page: " + _startPage);
                    float          newPosition = _startX + fullWidth;
                    ObjectAnimator animator    = ObjectAnimator.OfInt(_scroller, "scrollX", Convert.ToInt32(newPosition));
                    animator.Start();
                }
                else if (_endX < (_startX - (fullWidth / 2)))
                {
                    _startPage = _pagesStartAt.FirstOrDefault(x => x == _startX);
                    //Console.WriteLine ("Move Forward to next page: " + _startPage);
                    float          newPosition = _startX - fullWidth;
                    ObjectAnimator animator    = ObjectAnimator.OfInt(_scroller, "scrollX", Convert.ToInt32(newPosition));
                    animator.Start();
                }
                else
                {
                    //Console.WriteLine ("Move Backward to previous page: " + _startPage);
                    float          newPosition = _startX;
                    ObjectAnimator animator    = ObjectAnimator.OfInt(_scroller, "scrollX", Convert.ToInt32(newPosition));
                    animator.Start();
                }
                this.Parent.RequestDisallowInterceptTouchEvent(false);
                break;
            }

            return(base.OnTouchEvent(e));
        }