Esempio n. 1
0
 public async Task SnackBar(string message, TypeSnack typesnack)
 {
     if (typesnack == TypeSnack.Error)
     {
         Activity           activity                     = CrossCurrentActivity.Current.Activity;
         Android.Views.View activityRootView             = activity.FindViewById(Android.Resource.Id.Content);
         Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong);
         snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
         Android.Views.View snackbarview = snackBar.View;
         snackbarview.SetBackgroundResource(Resource.Drawable.snackerror);
         ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters;
         paramss.SetMargins(30, 0, 30, 40);
         snackbarview.SetBackground(
             MainActivity.CurrentActivity.ApplicationContext.GetDrawable(Resource.Drawable.snackerror));
         snackBar.Show();
     }
     else
     {
         Activity           activity                     = CrossCurrentActivity.Current.Activity;
         Android.Views.View activityRootView             = activity.FindViewById(Android.Resource.Id.Content);
         Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong);
         snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
         Android.Views.View snackbarview = snackBar.View;
         snackbarview.SetBackgroundResource(Resource.Drawable.snackBackground);
         ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters;
         paramss.SetMargins(30, 0, 30, 40);
         snackbarview.SetBackground(
             MainActivity.CurrentActivity.ApplicationContext.GetDrawable(Resource.Drawable.snackBackground));
         snackBar.Show();
     }
 }
Esempio n. 2
0
 public async Task SnackBarSucces(string message, string title, TypeSnackBar typeSnackBar)
 {
     if (typeSnackBar == TypeSnackBar.Bottom)
     {
         Activity           activity                     = CrossCurrentActivity.Current.Activity;
         Android.Views.View activityRootView             = activity.FindViewById(Android.Resource.Id.Content);
         Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong);
         snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
         Android.Views.View snackbarview = snackBar.View;
         snackbarview.SetBackgroundResource(Resource.Drawable.snackBackground);
         ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters;
         paramss.SetMargins(30, 0, 30, 40);
         snackbarview.LayoutParameters = paramss;
         snackbarview.SetBackground(
             MainActivity.Current.ApplicationContext.GetDrawable(Resource.Drawable.snackBackground));
         snackBar.Show();
     }
     else if (typeSnackBar == TypeSnackBar.Top)
     {
         CookieBar.Build(MainActivity.Current)
         .SetIcon(Resource.Drawable.ic_done)
         .SetTitle(title)
         .SetIconAnimation(Resource.Animator.iconspin)
         .SetBackgroundColor(Resource.Color.backgroundcoockiesuccess)
         .SetTitleColor(Resource.Color.cookiebartitle)
         .SetMessageColor(Resource.Color.cookiebartitle)
         .SetMessage(message)
         .SetEnableAutoDismiss(true)
         .SetSwipeToDismiss(true)
         .Show();
     }
 }
Esempio n. 3
0
        private void SetMargin(View child)
        {
            int margin = DpToPx(8);
            var param  = new ViewGroup.MarginLayoutParams(child.LayoutParameters);

            param.SetMargins(margin, margin, margin, margin);
            child.LayoutParameters = param;
        }
Esempio n. 4
0
 public static void SetMargins(this View v, int l, int t, int r, int b)
 {
     if (v.LayoutParameters is ViewGroup.MarginLayoutParams)
     {
         ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)v.LayoutParameters;
         p.SetMargins(l, t, r, b);
         v.RequestLayout();
     }
 }
Esempio n. 5
0
        private void SetMapviewMargin(int margin)
        {
            // Get the layout parameters for the container.
            ViewGroup.MarginLayoutParams parameters = (ViewGroup.MarginLayoutParams)_layoutContainer.LayoutParameters;

            // Set the margins.
            parameters.SetMargins(margin, margin, margin, margin);

            // Apply the layout.
            _layoutContainer.LayoutParameters = parameters;
        }
Esempio n. 6
0
        /**
         * Update Snackbar bottom margin
         */
        public void updateSnackbar(View child, View dependency)
        {
            if (dependency != null && dependency is Snackbar.SnackbarLayout)
            {
                snackbarLayout = (Snackbar.SnackbarLayout)dependency;
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
                {
                    snackbarLayout.AddOnLayoutChangeListener(
                        new CustomIOnLayoutChangeListener(
                            (View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) =>
                    {
                        if (floatingActionButton != null &&
                            floatingActionButton.LayoutParameters is ViewGroup.MarginLayoutParams)
                        {
                            ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)floatingActionButton.LayoutParameters;
                            snackBarY       = bottom - v.GetY();
                            fabTargetOffset = fabDefaultBottomMargin - child.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)(child.MeasuredHeight - child.TranslationY + snackBarY));
                        }
                    }
                            )
                        );
                }

                if (mSnackbarHeight == -1)
                {
                    mSnackbarHeight = dependency.Height;
                }

                int targetMargin = (int)(child.MeasuredHeight - child.TranslationY);
                if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
                {
                    child.BringToFront();
                }

                if (dependency.LayoutParameters is ViewGroup.MarginLayoutParams)
                {
                    ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)dependency.LayoutParameters;
                    p.SetMargins(p.LeftMargin, p.TopMargin, p.RightMargin, targetMargin);
                    dependency.RequestLayout();
                }
            }
        }
        /**
         * Update top margin with animation
         */
        public static void updateTopMargin(View view, int fromMargin, int toMargin)
        {
            ValueAnimator animator = ValueAnimator.OfFloat(fromMargin, toMargin);

            animator.SetDuration(150);
            animator.AddUpdateListener(
                new CustomViewPropertyIAnimatorUpdateListener((valueAnimator) =>
            {
                float animatedValue = (float)valueAnimator.AnimatedValue;
                if (view.LayoutParameters is ViewGroup.MarginLayoutParams)
                {
                    ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)view.LayoutParameters;
                    p.SetMargins(p.LeftMargin, (int)animatedValue, p.RightMargin, p.BottomMargin);
                    view.RequestLayout();
                }
            })
                );
            animator.Start();
        }
Esempio n. 8
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();
     }
 }
Esempio n. 9
0
        public void OnViewCreated(View view)
        {
            ScrollView = (HorizontalListView)view.FindViewById(Resource.Id.List1);
            sampleView = (FrameLayout)view.FindViewById(Resource.Id.SampleView);

            if (Samples.Count == 1)
            {
                ScrollView.Visibility = ViewStates.Gone;
                ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams)sampleView.LayoutParameters;

                param.SetMargins(0, 5, 0, 5);
            }
            else
            {
                adapter               = new ListViewAdapter(activity, Samples, CurrentIndex);
                ScrollView.Adapter    = adapter;
                ScrollView.ItemClick += OnListItemClick;
            }


            RefreshSample(CurrentSample);
        }
Esempio n. 10
0
        /**
         * Manage animation for Android < KITKAT
         *
         * @param child
         */
        private void ensureOrCancelObjectAnimation(T child, int offset, bool withAnimation)
        {
            if (translationObjectAnimator != null)
            {
                translationObjectAnimator.Cancel();
            }

            translationObjectAnimator = ObjectAnimator.OfFloat(child, /*View.TRANSLATION_Y*/ "translationY", offset);
            translationObjectAnimator.SetDuration(withAnimation ? ANIM_DURATION : 0);
            translationObjectAnimator.SetInterpolator(INTERPOLATOR);
            translationObjectAnimator.AddUpdateListener(
                new CustomViewPropertyIAnimatorUpdateListener((animation) =>
            {
                if (snackbarLayout != null && snackbarLayout.LayoutParameters is ViewGroup.MarginLayoutParams)
                {
                    targetOffset = child.MeasuredHeight - child.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 - child.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)(child.MeasuredHeight - child.TranslationY + snackBarY));
                }
            })
                );
        }