Exemplo n.º 1
0
        private AnimatorSet createContentTextShowAnimation(View currentContentText, View newContentText)
        {
            int         positionDeltaPx      = dpToPixels(CONTENT_TEXT_POS_DELTA_Y_DP);
            AnimatorSet animations           = new AnimatorSet();
            Animator    currentContentMoveUp = ObjectAnimator.OfFloat(currentContentText, "y", 0, -positionDeltaPx);

            currentContentMoveUp.SetDuration(ANIM_CONTENT_TEXT_HIDE_TIME);
            var endListener = new AnimatorEndListener();

            endListener.OnEndAnimation += () =>
            {
                mContentTextContainer.RemoveView(currentContentText);
            };
            currentContentMoveUp.AddListener(endListener);

            Animator currentContentFadeOut = ObjectAnimator.OfFloat(currentContentText, "alpha", 1, 0);

            currentContentFadeOut.SetDuration(ANIM_CONTENT_TEXT_HIDE_TIME);

            animations.PlayTogether(currentContentMoveUp, currentContentFadeOut);

            Animator newContentMoveUp = ObjectAnimator.OfFloat(newContentText, "y", positionDeltaPx, 0);

            newContentMoveUp.SetDuration(ANIM_CONTENT_TEXT_SHOW_TIME);

            Animator newContentFadeIn = ObjectAnimator.OfFloat(newContentText, "alpha", 0, 1);

            newContentFadeIn.SetDuration(ANIM_CONTENT_TEXT_SHOW_TIME);

            animations.PlayTogether(newContentMoveUp, newContentFadeIn);

            animations.SetInterpolator(new DecelerateInterpolator());

            return(animations);
        }
Exemplo n.º 2
0
        protected AnimatorSet createBGAnimatorSet(Android.Graphics.Color color)
        {
            View bgColorView = new ImageView(mAppContext);

            bgColorView.LayoutParameters = new RelativeLayout.LayoutParams(mRootLayout.Width, mRootLayout.Height);
            bgColorView.SetBackgroundColor(color);
            mBackgroundContainer.AddView(bgColorView);

            int[] pos = calculateCurrentCenterCoordinatesOfPagerElement(mActiveElementIndex);

            float finalRadius = mRootLayout.Width > mRootLayout.Height ? mRootLayout.Width : mRootLayout.Height;

            AnimatorSet bgAnimSet = new AnimatorSet();
            Animator    fadeIn    = ObjectAnimator.OfFloat(bgColorView, "alpha", 0, 1);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                Animator circularReveal = ViewAnimationUtils.CreateCircularReveal(bgColorView, pos[0], pos[1], 0, finalRadius);
                circularReveal.SetInterpolator(new AccelerateInterpolator());
                bgAnimSet.PlayTogether(circularReveal, fadeIn);
            }
            else
            {
                bgAnimSet.PlayTogether(fadeIn);
            }

            bgAnimSet.SetDuration(ANIM_BACKGROUND_TIME);
            var endListener = new AnimatorEndListener();

            endListener.OnEndAnimation += () =>
            {
                mRootLayout.SetBackgroundColor(color);
                bgColorView.Visibility = ViewStates.Gone;
                mBackgroundContainer.RemoveView(bgColorView);
            };
            bgAnimSet.AddListener(endListener);
            return(bgAnimSet);
        }