【发布时间】:2020-08-31 19:22:48
【问题描述】:
我正在尝试使用 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.Forms 的新手,所以不知道为什么会这样。
【问题讨论】:
标签: xaml xamarin.forms visual-studio-2017