xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] Xamarin Form Shell RelativeLayout iOS: page content starts lower than expected #8516

Open tim-wolfe opened 4 years ago

tim-wolfe commented 4 years ago

Description

The page content (Y) starts below the navigation bar and a top bar, even thought we do not have a top bar defined. Doesn't work on iOS but works as expected on Android.

Steps to Reproduce

  1. Shell
    <?xml version="1.0" encoding="UTF-8"?>
    <Shell xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:dashboard="clr-namespace:yyyyyy.Features.Dashboard"
       x:Class="yyyyyy.AppShell">
    <FlyoutItem Title="Dashboard">
        <dashboard:DashboardPage />
    </FlyoutItem>   
    </Shell>
  2. Dashboard Page with RelativeLayout
    <?xml version="1.0" encoding="UTF-8"?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="yyyyyy.Features.Dashboard.DashboardPage"
             Title="Dashboard">
    <ContentPage.Content>
        <RelativeLayout VerticalOptions="FillAndExpand">
            <StackLayout BackgroundColor="Lime"
                         VerticalOptions="FillAndExpand"
                         RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=X}"
                         RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Y}"
                         RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}"
                         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height}">
            </StackLayout>
        </RelativeLayout>
    </ContentPage.Content>
    </ContentPage>

    Expected Behavior

    The background color lime would fill all of the screen below the navigation bar.

Actual Behavior

There is a padding between the navigation bar and the RelativeLayout, I am assuming this is where the top tab bar would be.

Basic Information

Screenshots

Screen Shot 2019-11-14 at 6 08 17 PM

tim-wolfe commented 4 years ago

Found a work around and this info might be helpful for troubleshooting the problem:

            <StackLayout BackgroundColor="Lime"
                         VerticalOptions="FillAndExpand"
                         RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=X}"
                         RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0}"
                         RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}"
                         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height}">
            </StackLayout>

Changed the YConstraint property from Y to Height and added a factor with the value of 0. The StackLayout now starts at (0,0), right below navigation bar as expected.

hartez commented 4 years ago

_8516 Repro.zip