private SizeRequest?SizeRequestDelegate(NativeViewWrapperRenderer renderer,
                                                int widthConstraint, int heightConstraint)
        {
            var size = new Xamarin.Forms.Size(200, 200);

            return(new SizeRequest(size));
        }
        SizeRequest?FixSize(NativeViewWrapperRenderer renderer, int widthConstraint, int heightConstraint)
        {
            var nativeView = renderer.Control;

            if ((widthConstraint == 0 && heightConstraint == 0) || nativeView == null)
            {
                return(null);
            }

            int width     = Android.Views.View.MeasureSpec.GetSize(widthConstraint);
            int widthSpec = Android.Views.View.MeasureSpec.MakeMeasureSpec(width * 2, Android.Views.View.MeasureSpec.GetMode(widthConstraint));

            nativeView.Measure(widthSpec, heightConstraint);
            return(new SizeRequest(new Size(nativeView.MeasuredWidth, nativeView.MeasuredHeight)));
        }
        SizeRequest?FixSize(NativeViewWrapperRenderer renderer, double width, double height)
        {
            var uiView = renderer.Control;

            if (uiView == null)
            {
                return(null);
            }

            var constraint = new CGSize(width, height);

            // Let the CustomControl determine its size (which will be wrong)
            var badRect = uiView.SizeThatFits(constraint);

            // Use the width and substitute the height
            return(new SizeRequest(new Size(badRect.Width, 70)));
        }
示例#4
0
        SizeRequest?FixSize(NativeViewWrapperRenderer renderer, double width, double height)
        {
            var uiView = renderer.Control;
            var view   = renderer.Element;

            if (uiView == null || view == null)
            {
                return(null);
            }

            var constraint = new CGSize(width, height);

            // Let the BrokenNativeControl determine its size (which we know will be wrong)
            var badRect = uiView.SizeThatFits(constraint);

            // And we'll use the width (which is fine) and substitute our own height
            return(new SizeRequest(new Size(badRect.Width, 20)));
        }
示例#5
0
        static SizeRequest?SizeBrokenControl(NativeViewWrapperRenderer renderer,
                                             int widthConstraint, int heightConstraint)
        {
            global::Android.Views.View nativeView = renderer.Control;

            if ((widthConstraint == 0 && heightConstraint == 0) || nativeView == null)
            {
                return(null);
            }

            int width     = global::Android.Views.View.MeasureSpec.GetSize(widthConstraint);
            int widthSpec = global::Android.Views.View.MeasureSpec.MakeMeasureSpec(width * 2,
                                                                                   global::Android.Views.View.MeasureSpec.GetMode(widthConstraint));

            nativeView.Measure(widthSpec, heightConstraint);
            var size = new Size(nativeView.MeasuredWidth, nativeView.MeasuredHeight);

            return(new SizeRequest(size));
        }
		SizeRequest? FixSize (NativeViewWrapperRenderer renderer, int widthConstraint, int heightConstraint)
		{
			var nativeView = renderer.Control;

			if ((widthConstraint == 0 && heightConstraint == 0) || nativeView == null) {
				return null;
			}

			int width = Android.Views.View.MeasureSpec.GetSize (widthConstraint);
			int widthSpec = Android.Views.View.MeasureSpec.MakeMeasureSpec (width * 2, Android.Views.View.MeasureSpec.GetMode (widthConstraint));
			nativeView.Measure (widthSpec, heightConstraint);
			return new SizeRequest (new Size (nativeView.MeasuredWidth, nativeView.MeasuredHeight));
		}
		SizeRequest? FixSize (NativeViewWrapperRenderer renderer, double width, double height)
		{
			var uiView = renderer.Control;

			if (uiView == null) {
				return null;
			}

			var constraint = new CGSize (width, height);

			// Let the CustomControl determine its size (which will be wrong)
			var badRect = uiView.SizeThatFits (constraint);

			// Use the width and substitute the height
			return new SizeRequest (new Size (badRect.Width, 70));
		}