void AddMenu() { if (_basePage == null) { return; } var menu = _basePage.SlideMenu; if (menu == null) { return; } _basePage.HideMenuAction = () => { if (_dragGesture == null) { return; } var rect = _dragGesture.GetHidePosition(); _popMenuOverlayRenderer.View.Animate() .X((float)rect.left) .Y((float)rect.top) .SetDuration(menu.AnimationDurationMillisecond) .SetListener(new AnimatorListener(_dragGesture, false)) .Start(); }; _basePage.ShowMenuAction = () => { if (_dragGesture == null) { return; } var rect = _dragGesture.GetShowPosition(); _popMenuOverlayRenderer.View.Animate() .X((float)rect.left) .Y((float)rect.top) .SetDuration(menu.AnimationDurationMillisecond) .SetListener(new AnimatorListener(_dragGesture, true)) .Start(); }; if (_popMenuOverlayRenderer == null) { menu.Parent = (Page)_basePage; _popMenuOverlayRenderer = Platform.CreateRendererWithContext(menu, _context); Platform.SetRenderer(menu, _popupRenderer); var metrics = _pageRenderer.Resources.DisplayMetrics; var rootView = _popMenuOverlayRenderer.View; if (_popMenuOverlayRenderer is SlideMenuDroidRenderer) { _dragGesture = (_popMenuOverlayRenderer as SlideMenuDroidRenderer).GragGesture; } if (_dragGesture == null) { return; } var rect = _dragGesture.GetHidePosition(); menu.Layout(new Xamarin.Forms.Rectangle( rect.left / metrics.Density, rect.top / metrics.Density, (rect.right - rect.left) / metrics.Density, (rect.bottom - rect.top) / metrics.Density)); _popMenuOverlayRenderer.UpdateLayout(); _popMenuOverlayRenderer.View.Visibility = ViewStates.Visible; rootView.Layout((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom); _pageRenderer.ViewGroup.AddView(rootView); _pageRenderer.ViewGroup.BringChildToFront(rootView); _dragGesture.NeedShowBackgroundView = (open, alpha) => { if (open) { ShowBackgroundOverlay(alpha); } else { HideBackgroundOverlay(); } }; } }