Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

RelativeLayout not responding to user-input in iOS

Hi everyone

For some reason an entry in iOS isn't responding to any user-input once it is programmatically added to a RelativeLayout while it does work in Android.


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""

    <Image x:Name="imgTest" />

    <StackLayout Orientation="Vertical" Padding="15, 70, 15, 2">
      <Entry TextColor="Black" BackgroundColor="Blue" />



namespace TempProject.Pages
    public partial class FullRelativeLayoutPage : ContentPage
        public FullRelativeLayoutPage()

        protected override void OnAppearing()

            var relativeLayout = new RelativeLayout();
            relativeLayout.InputTransparent = true;

                Constraint.RelativeToParent((parent) => 1 * parent.X),
                Constraint.RelativeToParent((parent) => 1 * parent.Y),
                Constraint.RelativeToParent((parent) => 1 * parent.Width),
                Constraint.RelativeToParent((parent) => 1 * parent.Height)

            Content = relativeLayout;

How come in Android this entry is editable, but in iOS it is not? FYI a button is not responding either.


  • StefaanAvonds.3725StefaanAvonds.3725 USMember ✭✭✭

    I've tried to make a custom renderer to convert the controls to the native UIView so these could be added to a new UICollectionView:

        public class BaseRelativeLayoutRenderer : ViewRenderer<RelativeLayout, UIView>
            protected override void OnElementChanged(ElementChangedEventArgs<RelativeLayout> e)
                if (e.NewElement == null) return;
                var fullSize = new CoreGraphics.CGRect(e.NewElement.X, e.NewElement.Y, e.NewElement.Width, e.NewElement.Height);
                var native = new UICollectionView(fullSize, new UICollectionViewLayout());
                foreach (var item in e.NewElement.Children)
                    var renderer = Platform.CreateRenderer(item);
                    var size = new CoreGraphics.CGRect(item.X, item.Y, item.Width, item.Height);
                    renderer.NativeView.Frame = size;
                    renderer.NativeView.AutoresizingMask = UIViewAutoresizing.All;
                    renderer.NativeView.ContentMode = UIViewContentMode.ScaleToFill;

    This almost works: both an entry and a button respond to the users interactions, but some things still aren't rendered correctly. For example a ScrollView isn't working anymore (scroll is disabled). Also the Syncfusion SfDataGrid is rendered twice, but only one is scrollable while the other just stays still in the background ...

    Anyone know what the solution is, or how to edit the custom renderer from above?

Sign In or Register to comment.