private void updateSnackBarPosition(CoordinatorLayout parent, V child, View dependency, float translationY)
 {
     if (dependency != null && dependency is Snackbar.SnackbarLayout)
     {
         ViewCompat.Animate(dependency).SetInterpolator(INTERPOLATOR).SetDuration(80).SetStartDelay(0).TranslationY(translationY).Start();
     }
 }
示例#2
0
 /// <param name="animate"> whether to animate the change </param>
 /// <returns> this, to allow builder pattern </returns>
 public virtual BadgeItem Show(bool animate)
 {
     mIsHidden = false;
     if (WeakReferenceValid)
     {
         TextView textView = (TextView)mTextViewRef.Get();
         if (animate)
         {
             textView.ScaleX     = 0;
             textView.ScaleY     = 0;
             textView.Visibility = ViewStates.Visible;
             ViewPropertyAnimatorCompat animatorCompat = ViewCompat.Animate(textView);
             animatorCompat.Cancel();
             animatorCompat.SetDuration(mAnimationDuration);
             animatorCompat.ScaleX(1).ScaleY(1);
             animatorCompat.SetListener(null);
             animatorCompat.Start();
         }
         else
         {
             textView.ScaleX     = 1;
             textView.ScaleY     = 1;
             textView.Visibility = ViewStates.Visible;
         }
     }
     return(this);
 }
示例#3
0
        /// <summary>
        /// This method initiates the bottomNavigationBar and handles layout related values
        /// </summary>
        private void init()
        {
            //        MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int) getContext().getResources().GetDimension(Resource.Dimension.bottom_navigation_padded_height)));
            //        marginParams.setMargins(0, (int) getContext().getResources().GetDimension(Resource.Dimension.bottom_navigation_top_margin_correction), 0, 0);

            LayoutParameters = new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent));

            LayoutInflater inflater   = LayoutInflater.From(Context);
            View           parentView = inflater.Inflate(Resource.Layout.bottom_navigation_bar_container, this, true);

            mBackgroundOverlay = (FrameLayout)parentView.FindViewById(Resource.Id.bottom_navigation_bar_overLay);
            mContainer         = (FrameLayout)parentView.FindViewById(Resource.Id.bottom_navigation_bar_container);
            mTabContainer      = (LinearLayout)parentView.FindViewById(Resource.Id.bottom_navigation_bar_item_container);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                this.OutlineProvider = ViewOutlineProvider.Bounds;
            }
            else
            {
                //to do
            }

            ViewCompat.SetElevation(this, mElevation);
            SetClipToPadding(false);
        }
 static void OnLayoutChange(object sender, global::Android.Views.View.LayoutChangeEventArgs e)
 {
     if (sender is IVisualElementRenderer renderer && renderer.View is ImageView imageView)
     {
         AViewCompat.SetClipBounds(imageView, imageView.GetScaleType() == AScaleType.CenterCrop ? new ARect(0, 0, e.Right - e.Left, e.Bottom - e.Top) : null);
     }
 }
示例#5
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            AViewCompat.SetClipBounds(this, new Rect(0, 0, Width, Height));

            // After a direct (non-animated) scroll operation, we may need to make adjustments
            // to align the target item; if an adjustment is pending, execute it here.
            // (Deliberately checking the private member here rather than the property accessor; the accessor will
            // create a new ScrollHelper if needed, and there's no reason to do that until a Scroll is requested.)
            _scrollHelper?.AdjustScroll();
        }
示例#6
0
        //    public void setmFabBehaviour(int mFabBehaviour) {
        //        this.mFabBehaviour = mFabBehaviour;
        //    }

        ///////////////////////////////////////////////////////////////////////////
        // Animator Initializer
        ///////////////////////////////////////////////////////////////////////////

        private void ensureOrCancelAnimator(FloatingActionButton fab)
        {
            if (mFabTranslationYAnimator == null)
            {
                mFabTranslationYAnimator = ViewCompat.Animate(fab);
                mFabTranslationYAnimator.SetDuration(400);
                mFabTranslationYAnimator.SetInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
            }
            else
            {
                mFabTranslationYAnimator.Cancel();
            }
        }
示例#7
0
        /// <summary>
        /// Internal Method
        /// <para>
        /// used to set animation and
        /// takes care of cancelling current animation
        /// and sets duration and interpolator for animation
        ///
        /// </para>
        /// </summary>
        /// <param name="offset"> translation offset that needs to set with animation </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void animateOffset(final int offset)
        private void animateOffset(int offset)
        {
            if (mTranslationAnimator == null)
            {
                mTranslationAnimator = ViewCompat.Animate(this);
                mTranslationAnimator.SetDuration(mRippleAnimationDuration);
                mTranslationAnimator.SetInterpolator(INTERPOLATOR);
            }
            else
            {
                mTranslationAnimator.Cancel();
            }
            mTranslationAnimator.TranslationY(offset).Start();
        }
示例#8
0
            public void OnAttach()
            {
                _isAttached = true;
#if V4COMPAT
                ViewCompat.postOnAnimation(target, () =>
                {
                    if (isAttached)
                    {
                        target.invalidate();
                        ViewCompat.postOnAnimation(target, this);
                    }
                });
                                #else
                AnimationHandler();
#endif
            }
示例#9
0
        ///////////////////////////////////////////////////////////////////////////
        // Animating Fab based on Changes
        ///////////////////////////////////////////////////////////////////////////

        private void updateFabTranslationForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab, View dependency)
        {
            float snackBarTranslation = getFabTranslationYForSnackBar(parent, fab);

            float[] bottomBarParameters  = getFabTranslationYForBottomNavigationBar(parent, fab);
            float   bottomBarTranslation = bottomBarParameters[0];
            float   bottomBarHeight      = bottomBarParameters[1];

            float targetTransY = 0;

            if (snackBarTranslation >= bottomBarTranslation)
            {
                // when snackBar is below BottomBar in translation present.
                targetTransY = bottomBarTranslation;
            }
            else
            {
                targetTransY = snackBarTranslation;
            }

            //        if (mFabBehaviour == BottomNavigationBar.FAB_BEHAVIOUR_DISAPPEAR) {
            //            if (targetTransY == 0) {
            //                fab.hide();
            //            } else {
            //                fab.show();
            //            }
            //        }

            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final float currentTransY = Android.Support.V4.View.ViewCompat.getTranslationY(fab);
            float currentTransY = ViewCompat.GetTranslationY(fab);

            // Make sure that any current animation is cancelled
            ensureOrCancelAnimator(fab);


            if (fab.IsShown && Math.Abs(currentTransY - targetTransY) > (fab.Height * 0.667f))
            {
                // If the FAB will be travelling by more than 2/3 of it's height, let's animate it instead
                mFabTranslationYAnimator.TranslationY(targetTransY).Start();
            }
            else
            {
                // Now update the translation Y
                ViewCompat.SetTranslationY(fab, targetTransY);
            }
        }
示例#10
0
        private float getFabTranslationYForSnackBar(CoordinatorLayout parent, FloatingActionButton fab)
        {
            float minOffset = 0;
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final java.util.List<Android.View.View> dependencies = parent.getDependencies(fab);
            IList <View> dependencies = parent.GetDependencies(fab);

            for (int i = 0, z = dependencies.Count; i < z; i++)
            {
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Android.View.View view = dependencies.get(i);
                View view = dependencies[i];
                if (view is Snackbar.SnackbarLayout && parent.DoViewsOverlap(fab, view))
                {
                    minOffset = Math.Min(minOffset, ViewCompat.GetTranslationY(view) - view.Height);
                }
            }

            return(minOffset);
        }
示例#11
0
 /// <param name="animate"> whether to animate the change </param>
 /// <returns> this, to allow builder pattern </returns>
 public virtual BadgeItem Hide(bool animate)
 {
     mIsHidden = true;
     if (WeakReferenceValid)
     {
         TextView textView = (TextView)mTextViewRef.Get();
         if (animate)
         {
             ViewPropertyAnimatorCompat animatorCompat = ViewCompat.Animate(textView);
             animatorCompat.Cancel();
             animatorCompat.SetDuration(mAnimationDuration);
             animatorCompat.ScaleX(0).ScaleY(0);
             animatorCompat.SetListener(new ViewPropertyAnimatorListenerAnonymousInnerClass(this));
             animatorCompat.Start();
         }
         else
         {
             textView.Visibility = ViewStates.Gone;
         }
     }
     return(this);
 }
示例#12
0
        ///////////////////////////////////////////////////////////////////////////
        // Fab Translation due to SnackBar and Due to BottomBar
        ///////////////////////////////////////////////////////////////////////////

        private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab)
        {
            float minOffset  = 0;
            float viewHeight = 0;
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final java.util.List<Android.View.View> dependencies = parent.getDependencies(fab);
            IList <View> dependencies = parent.GetDependencies(fab);

            for (int i = 0, z = dependencies.Count; i < z; i++)
            {
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Android.View.View view = dependencies.get(i);
                View view = dependencies[i];
                if (view is BottomNavigationBar)
                {
                    viewHeight = view.Height;
                    minOffset  = Math.Min(minOffset, ViewCompat.GetTranslationY(view) - viewHeight);
                }
            }
            float[] returnValues = new float[] { minOffset, viewHeight };

            return(returnValues);
        }
 private void updateSnackBarPosition(CoordinatorLayout parent, V child, View dependency)
 {
     updateSnackBarPosition(parent, child, dependency, ViewCompat.GetTranslationY(child) - child.Height);
 }