예제 #1
0
 private void EnsureOrCancelAnimator(View child)
 {
     if (translationAnimator == null)
     {
         translationAnimator = ViewCompat.Animate(child);
         translationAnimator.SetDuration(300);
         translationAnimator.SetInterpolator(InInterpolator);
     }
     else
     {
         translationAnimator.Cancel();
     }
 }
예제 #2
0
        public override bool OnDependentViewChanged(CoordinatorLayout parent, Java.Lang.Object child, View dependency)
        {
            View _child = child as View;

            if (_child.TranslationY > 0)
            {
                return(true);
            }
            if (animation != null)
            {
                animation.Cancel();
                animation = null;
            }
            _child.TranslationY = Math.Min(0f, dependency.TranslationY - dependency.Height);
            return(true);
        }
예제 #3
0
 //public override bool LayoutDependsOn(CoordinatorLayout parent, Java.Lang.Object child, View dependency)
 //{
 //    var s = dependency is AppBarLayout;
 //    return base.LayoutDependsOn(parent, child, dependency);
 //}
 //public override bool OnDependentViewChanged(CoordinatorLayout parent, Java.Lang.Object child, View dependency)
 //{
 //    //float scaleY = System.Math.Abs(dependency.GetY());
 //    //View _child = child as View;
 //    ////child.TranslationY
 //    //AnimateOffset(_child);
 //    return true;
 //    // return base.OnDependentViewChanged(parent, child, dependency);
 //}
 void AnimateOffset(View child, ScrollDirection scrollDirection)
 {
     if (translationAnimator == null)
     {
         translationAnimator = ViewCompat.Animate(child);
         translationAnimator.SetDuration(300);
         translationAnimator.SetInterpolator(InInterpolator);
     }
     else
     {
         translationAnimator.Cancel();
     }
     if (scrollDirection == ScrollDirection.Up)
     {
         translationAnimator.TranslationY(child.Height).Start();
     }
     else if (scrollDirection == ScrollDirection.Down)
     {
         translationAnimator.TranslationY(0).Start();
     }
 }
예제 #4
0
 /**
  * Manage animation for Android >= KITKAT
  *
  * @param child
  */
 private void ensureOrCancelAnimator(T child, bool withAnimation)
 {
     if (translationAnimator == null)
     {
         translationAnimator = ViewCompat.Animate(child);
         translationAnimator.SetDuration(withAnimation ? ANIM_DURATION : 0);
         translationAnimator.SetUpdateListener(
             new CustomViewPropertyAnimatorUpdateListener((view) =>
         {
             // Animate snackbar
             if (snackbarLayout != null && snackbarLayout.LayoutParameters is ViewGroup.MarginLayoutParams)
             {
                 targetOffset = view.MeasuredHeight - view.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 - view.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)(view.MeasuredHeight - view.TranslationY + snackBarY));
             }
         })
             );
         translationAnimator.SetInterpolator(INTERPOLATOR);
     }
     else
     {
         translationAnimator.SetDuration(withAnimation ? ANIM_DURATION : 0);
         translationAnimator.Cancel();
     }
 }