protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            using (var h = new Handler(Looper.MainLooper)) {
                h.Post(() => {
                    double width  = base.Context.FromPixels((double)(r - l));
                    double height = base.Context.FromPixels((double)(b - t));
                    var size      = new Size(width, height);

                    var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
                    var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);
                    _nativeView.Measure(msw, msh);
                    _nativeView.Layout(0, 0, r - l, b - t);

                    //			if (size != _previousSize) {
                    var layout = _viewCell.View as Layout <Xamarin.Forms.View>;
                    if (layout != null)
                    {
                        layout.Layout(new Rectangle(0, 0, width, height));
                        layout.ForceLayout();
                        FixChildLayouts(layout);
                        _isLaidOut = true;
                    }
                    _previousSize = size;
                });
            }
            //			}
        }
            // Because FastRenderer of Label or Image can't be set ClickListener,
            // insert FrameLayout with same position and same size on the view.
            public void OnLayoutChange(Android.Views.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
            {
                _overlay.Layout(v.Left, v.Top, v.Right, v.Bottom);

                if (_alreadyGotParent)
                {
                    return;
                }

                _parent           = _view.Parent as Android.Views.ViewGroup;
                _alreadyGotParent = true;

                _parent.AddView(_overlay);

                _overlay.BringToFront();
            }
Exemple #3
0
        public Bitmap MakeIcon()
        {
            int measureSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);

            _container.Measure(measureSpec, measureSpec);

            int measuredWidth  = _textView.MeasuredWidth;
            int measuredHeight = _textView.MeasuredHeight;

            _container.Layout(0, 0, measuredWidth, measuredHeight);

            var bubbleDrawable = _context.Resources.GetDrawable(Resource.Drawable.bubble);

            bubbleDrawable.SetBounds(0, 0, measuredWidth, measuredHeight);

            var bitmap = Bitmap.CreateBitmap(measuredWidth, measuredHeight, Bitmap.Config.Argb8888);
            var canvas = new Canvas(bitmap);

            bubbleDrawable.Draw(canvas);
            _container.Draw(canvas);

            return(bitmap);
        }