public SizeRequest GetDesiredSize(int widthConstraint, int heightConstraint)
        {
            packed.Measure(widthConstraint, heightConstraint);

            //Measure child here and determine size
            return(new SizeRequest(new Size(packed.MeasuredWidth, packed.MeasuredHeight)));
        }
        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;
                });
            }
            //			}
        }
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);
        }
 public SizeRequest GetDesiredSize(int widthConstraint, int heightConstraint)
 {
     packed.Measure(widthConstraint, heightConstraint);
     return(new SizeRequest(new Size(packed.MeasuredWidth, packed.MeasuredHeight)));
 }