Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Bug: RelativeLayout Not Obeying Padding or LayoutOptions

JLundaJLunda USMember ✭✭

Xamarin Team,

I have been trying to use RelativeLayout for my application, and I've also been trying to abstract the Padding and LayoutOptions for this layout to an application-level ResourceDictionary.

I've tried simplifying this down to a very simple case where I have the following in my application-level ResourceDictionary:

  <LayoutOptions x:Key="RelativeLayout_HorizontalOptions"
                 Expands="True" />

  <LayoutOptions x:Key="RelativeLayout_VerticalOptions"
    Expands="False" />


And I have the following markup in my RelativeLayout:
<RelativeLayout Padding="50" BackgroundColor="Red" HorizontalOptions="{StaticResource RelativeLayout_HorizontalOptions}" VerticalOptions="{StaticResource RelativeLayout_VerticalOptions}"> <Label Text="Test Label" /> </RelativeLayout>

When the layout is a RelativeLayout the padding is not obeyed at all, but the Alignment for the LayoutOptions is obeyed, while the Expands Boolean is not obeyed. I originally thought this may be because of an inability to parse a String to a Boolean, but this is not the case, as far as I can tell, since the example here shows LayoutOptions done in exactly this way, and the Boolean structure documentation clearly states that the String representation of a Boolean is either "True" or "False", in order for it to be parse-able.

Switching the RelativeLayout to a StackLayout causes the Padding StaticResource definition to be obeyed, but, just as in the case of RelativeLayout, the StackLayout only obeys the Alignment property of the LayoutOptions StaticResource and not the Expands property.

Please look into this bug, since it is at such a fundamental level.


  • shihaonanshihaonan Member ✭✭

    5-24-2018 this issue still exists. :/

  • SuperCorksSuperCorks Member ✭✭

    Still ongoing (2019-01-15)

  • SuperCorksSuperCorks Member ✭✭

    PS. To solve this issue, just wrap the relative layout in a stack layout

        <!-- Wrapping the relative layout in a stack layout because Relative layout includes
                the padding of the parent when calculating height. Ugh...
Sign In or Register to comment.