Exemplo n.º 1
0
        private static void Initialize(FrameLayout rootView)
        {
            var layoutParent = new LinearLayout(_activity.ApplicationContext);

            _layoutCenter = new LinearLayout(_activity.ApplicationContext);
            _layoutImage  = new LinearLayout(_activity.ApplicationContext);

            var layoutParentParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            layoutParent.LayoutParameters = layoutParentParameters;
            layoutParent.SetBackgroundDrawable(_activity.Resources.GetDrawable(Resource.Drawable.loading_overlay));

            var layoutCenterParameters = new LinearLayout.LayoutParams(-2, 0);

            layoutCenterParameters.Weight = 1.0f;
            layoutCenterParameters.SetMargins(0, 0, 0, 0);
            layoutCenterParameters.Gravity = GravityFlags.CenterVertical;

            var layoutImageParameters = new LinearLayout.LayoutParams(-1, -1);

            layoutCenterParameters.Weight = 1.0f;
            layoutCenterParameters.SetMargins(0, 0, 0, 0);

            _layoutCenter.LayoutParameters = layoutCenterParameters;
            _layoutCenter.SetBackgroundColor(Android.Graphics.Color.White);

            _layoutImage.LayoutParameters = layoutImageParameters;

            _layoutCenter.AddView(_layoutImage);
            layoutParent.AddView(_layoutCenter);

            rootView.AddView(layoutParent, layoutParentParameters);
            layoutParent.BringToFront();

            _layoutCenter.ClearAnimation();
            _layoutImage.SetBackgroundDrawable(null);

            if (_car == null)
            {
                _colorToUse = _activity.Resources.GetColor(Resource.Color.company_color);
                _car        = DrawHelper.ApplyThemeColorToImage(Resource.Drawable.taxi_progress, true, new SizeF(52, 20), Android.Graphics.Color.Argb(255, 0, 122, 255), new System.Drawing.Point(25, 10));
            }

            var displaySize  = _activity.Resources.DisplayMetrics;
            var windowHeight = (int)(_car.Width * 1.5f);

            _windowSize = new Size(displaySize.WidthPixels, windowHeight);

            var _radius = _car.Width * 1.3f;

            _zoneCircle = new RectF((_windowSize.Width * 0.5f) - _radius / 2f, (_windowSize.Height * 0.5f) - _radius / 2f, (_windowSize.Width * 0.5f) + _radius / 2f, (_windowSize.Height * 0.5f) + _radius / 2f);

            StartAnimationLoop(layoutParent);
        }