Xaml 为什么我的Xamarin.Forms控件在StackLayout中重叠?

Xaml 为什么我的Xamarin.Forms控件在StackLayout中重叠?,xaml,xamarin.forms,visual-studio-2017,Xaml,Xamarin.forms,Visual Studio 2017,我正在尝试使用StackLayout设计登录页面。我认为每个项目应该从上到下线性显示,但由于某些原因,控件重叠。以下是我的.xaml文件代码: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

我正在尝试使用StackLayout设计登录页面。我认为每个项目应该从上到下线性显示,但由于某些原因,控件重叠。以下是我的.xaml文件代码:

<?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="DJB.Views.LoginPage"
             xmlns:local="clr-namespace:DJB.Controls">

    <ContentPage.Content>
        <StackLayout>
            <Image Source="djblogowithtext" Margin="30,30"></Image>
            <!-- UserName -->
            <Label Text="Username" HorizontalTextAlignment="Center" HeightRequest="15" Margin="1"/>
            <StackLayout BackgroundColor="LightGray" Padding="1" Margin="30,0" HeightRequest="20">
                <local:TextEntry BackgroundColor="White" VerticalOptions="FillAndExpand"/>
            </StackLayout>
            <!-- Password -->
            <Label Text="Password" HorizontalTextAlignment="Center" HeightRequest="15" Margin="1"/>
            <StackLayout BackgroundColor="LightGray" Padding="1" Margin="30,0" HeightRequest="20">
                <local:TextEntry BackgroundColor="White" VerticalOptions="FillAndExpand" />
            </StackLayout>

            <Button Text="Login" Margin="30" BackgroundColor="#f7ebeb" Clicked="Login_Clicked"> </Button>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

以下是Android上的外观:


我相信这确实很简单,但我是Xamarin的新手。所以我不确定为什么会出现这种情况。

您指定的控件高度不够大,无法容纳其内容。要么根本不使用一个控件,让控件自行调整大小,要么使用一个足以容纳内容的值

<Label Text="Username" HorizontalTextAlignment="Center" HeightRequest="15" Margin="1"/>


带有默认字体的标签可能需要30或更高,而不是15

Thank@Jason。我去掉了身高要求线,现在看起来很好。