private void RemoveCroutonFromViewParent(Crouton crouton)
 {
     if (crouton.IsShowing())
     {
         var parent = (ViewGroup)crouton.GetView().Parent;
         if (null != parent)
         {
             parent.RemoveView(crouton.GetView());
         }
     }
 }
        /**
         * Adds a {@link Crouton} to the {@link ViewParent} of it's {@link Activity}.
         *
         * @param crouton
         *     The {@link Crouton} that should be added.
         */

        private void AddCroutonToView(Crouton crouton)
        {
            // don't Add if it is already showing
            if (crouton.IsShowing())
            {
                return;
            }

            View croutonView = crouton.GetView();

            if (null == croutonView.Parent)
            {
                ViewGroup.LayoutParams parameters = croutonView.LayoutParameters;
                if (null == parameters)
                {
                    parameters = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                  ViewGroup.LayoutParams.WrapContent);
                }
                // display Crouton in ViewGroup is it has been supplied
                if (null != crouton.GetViewGroup())
                {
                    ViewGroup croutonViewGroup = crouton.GetViewGroup();
                    if (ShouldAddViewWithoutPosition(croutonViewGroup))
                    {
                        croutonViewGroup.AddView(croutonView, parameters);
                    }
                    else
                    {
                        croutonViewGroup.AddView(croutonView, 0, parameters);
                    }
                }
                else
                {
                    Activity activity = crouton.GetActivity();
                    if (null == activity || activity.IsFinishing)
                    {
                        return;
                    }
                    HandleTranslucentActionBar((ViewGroup.MarginLayoutParams)parameters, activity);
                    HandleActionBarOverlay((ViewGroup.MarginLayoutParams)parameters, activity);

                    activity.AddContentView(croutonView, parameters);
                }
            }

            croutonView.RequestLayout(); // This is needed so the animation can use the measured with/height
            ViewTreeObserver observer = croutonView.ViewTreeObserver;

            if (null != observer)
            {
                CallOnGlobalLayout(crouton, croutonView);
            }
        }