Example #1
0
        void Initialize()
        {
            OnceInitializeAction = null;

            ContentView.SetBackgroundColor(_loadingView.OverlayColor.ToAndroid());
            ContentView.Alpha = 1f;
            ContentView.SetPadding(0, (int)Dialogs.Context.ToPixels(24), 0, 0); // Statusbar

            _loadingView.Parent = XF.Application.Current.MainPage;

            _renderer = Dialogs.CreateNativeView(_loadingView);

            if (_loadingView.CornerRadius > 0)
            {
                var nativeView = _renderer.View as ViewGroup;
                var border     = new GradientDrawable();
                border.SetCornerRadius(Dialogs.Context.ToPixels(_loadingView.CornerRadius));
                if (!_loadingView.BackgroundColor.IsDefault)
                {
                    border.SetColor(_loadingView.BackgroundColor.ToAndroid());
                }
                nativeView.ClipToOutline = true;
                nativeView.SetBackground(border);
            }

            var measure = Dialogs.Measure(_loadingView);

            _loadingView.Layout(new XF.Rectangle(0, 0, measure.Width, measure.Height));


            var width  = (int)Dialogs.Context.ToPixels(_loadingView.Bounds.Width);
            var height = (int)Dialogs.Context.ToPixels(_loadingView.Bounds.Height);

            using (var param = new FrameLayout.LayoutParams(
                       ViewGroup.LayoutParams.WrapContent,
                       ViewGroup.LayoutParams.WrapContent
                       )
            {
                Width = width,
                Height = height,
                Gravity = Dialogs.GetGravity(_loadingView)
            })
            {
                Dialogs.SetOffsetMargin(param, _loadingView);
                ContentView.AddView(_renderer.View, 0, param);
            }
        }