void Initialize() { _dlgView.Parent = XF.Application.Current.MainPage; _renderer = Dialogs.CreateNativeView(_dlgView); var measure = Dialogs.Measure(_dlgView); _dlgView.Layout(new XF.Rectangle(0, 0, measure.Width, measure.Height)); _container = Dialogs.SetViewAppearance(_dlgView, _renderer.View as ViewGroup); _contentView = new FrameLayout(Dialogs.Context); using (var param = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)) { _contentView.LayoutParameters = param; } var fixPaddingTop = _dlgView.OverlayColor.IsTransparentOrDefault() ? Dialogs.StatusBarHeight : 0; if (_dlgView.UseCurrentPageLocation) { var padding = Dialogs.CalcWindowPadding(); _contentView.SetPadding(0, padding.top - fixPaddingTop, 0, padding.bottom); } else { _contentView.SetPadding(0, Dialogs.StatusBarHeight - fixPaddingTop, 0, 0); } _contentView.SetBackgroundColor(_dlgView.OverlayColor.ToAndroid()); _contentView.SetClipChildren(false); _contentView.SetClipToPadding(false); _contentView.FocusableInTouchMode = true; _contentView.Touch += _contentView_Touch; var width = Dialogs.Context.ToPixels(_dlgView.Bounds.Width); var height = Dialogs.Context.ToPixels(_dlgView.Bounds.Height); using (var param = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Width = (int)width, Height = (int)height, Gravity = Dialogs.GetGravity(_dlgView), }) { Dialogs.SetOffsetMargin(param, _dlgView); _contentView.AddView(_container, 0, param); }; // For now, Dynamic resizing is gaven to only Dialog. _dlgView.LayoutNative = () => { if (_renderer == null || _renderer.View.IsDisposed()) { return; } var p = _renderer.View.LayoutParameters as FrameLayout.LayoutParams; var w = (int)Dialogs.Context.ToPixels(_dlgView.Bounds.Width); var h = (int)Dialogs.Context.ToPixels(_dlgView.Bounds.Height); using (var param = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Width = w, Height = h, Gravity = p.Gravity }) { Dialogs.SetOffsetMargin(param, _dlgView); _renderer.View.LayoutParameters = param; }; }; OnceInitializeAction = null; }
void Initialize() { _dlgView.Parent = XF.Application.Current.MainPage; _renderer = Dialogs.CreateNativeView(_dlgView); var measure = Dialogs.Measure(_dlgView); _dlgView.Layout(new XF.Rectangle(0, 0, measure.Width, measure.Height)); if (_dlgView.CornerRadius > 0) { var nativeView = _renderer.View as ViewGroup; var border = new GradientDrawable(); border.SetCornerRadius(Dialogs.Context.ToPixels(_dlgView.CornerRadius)); if (!_dlgView.BackgroundColor.IsDefault) { border.SetColor(_dlgView.BackgroundColor.ToAndroid()); } nativeView.ClipToOutline = true; nativeView.SetBackground(border); } _contentView = new FrameLayout(Dialogs.Context); using (var param = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)) { _contentView.LayoutParameters = param; } if (_dlgView.UseCurrentPageLocation) { var padding = Dialogs.CalcWindowPadding(); _contentView.SetPadding(0, padding.top, 0, padding.bottom); } else { _contentView.SetPadding(0, (int)Dialogs.Context.ToPixels(24), 0, 0); // Statusbar } _contentView.SetBackgroundColor(_dlgView.OverlayColor.ToAndroid()); _contentView.SetClipChildren(false); _contentView.SetClipToPadding(false); _contentView.SetOnKeyListener(this); _contentView.FocusableInTouchMode = true; _contentView.Touch += _contentView_Touch; var width = Dialogs.Context.ToPixels(_dlgView.Bounds.Width); var height = Dialogs.Context.ToPixels(_dlgView.Bounds.Height); using (var param = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Width = (int)width, Height = (int)height, Gravity = Dialogs.GetGravity(_dlgView), }) { Dialogs.SetOffsetMargin(param, _dlgView); _contentView.AddView(_renderer.View, 0, param); }; OnceInitializeAction = null; }