예제 #1
0
 private void EnsureOrCancelAnimator(View child)
 {
     if (translationAnimator == null)
     {
         translationAnimator = ViewCompat.Animate(child);
         translationAnimator.SetDuration(300);
         translationAnimator.SetInterpolator(InInterpolator);
     }
     else
     {
         translationAnimator.Cancel();
     }
 }
 private void EnsureOrCancelAnimator(V child)
 {
     if (_mTranslationAnimator == null)
     {
         _mTranslationAnimator = ViewCompat.Animate(child);
         _mTranslationAnimator.SetDuration(300);
         _mTranslationAnimator.SetInterpolator(INTERPOLATOR);
     }
     else
     {
         _mTranslationAnimator.Cancel();
     }
 }
예제 #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();
     }
 }