Xaml Xamarin表单标签定位
我是新手。我使用XAML&Xamarin在页面顶部添加了一个标签,但是标签太靠近页面顶部,所以它被当前的iPad所掩盖 正在使用的XAML代码是:Xaml Xamarin表单标签定位,xaml,xamarin.ios,Xaml,Xamarin.ios,我是新手。我使用XAML&Xamarin在页面顶部添加了一个标签,但是标签太靠近页面顶部,所以它被当前的iPad所掩盖 正在使用的XAML代码是: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx
<?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="XamlSamples.HelloXamlPage"
Title="XAML + Code Page">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="#000000" Spacing="0" Padding="-300,-1,-300,29">
<Label Text="Text here"
Font="Large"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
Style="{DynamicResource TitleStyle}"/>
</StackLayout>
</ContentPage>
看看你的堆栈填充(Padding=“-300,-1,-300,29”)有点奇怪, 此外,您还可以添加一些带有填充的布局
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="#000000" Spacing="0" Padding="-300,-1,-300,29">
<Grid Padding="20 "/>
<Label Text="Text here"
Font="Large"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
Style="{DynamicResource TitleStyle}"/>
将填充改为
Padding="x, 20, y, z"
在iOS中,状态栏的高度为20像素,并在确定页面上的位置时包括在内(意味着y的y位置位于状态栏顶部,类似于页面)。在确定页面上的位置时,Windows和Android不包括状态栏的高度(表示状态栏底部的y位置为0)。还应该注意的是,在某些情况下,状态栏实际上可能有40像素高(在我读到的调用中)
跨平台选项的建议用途如下:
< ContentPage.Padding >
<!-- set platform - specific padding
iOS needs an additional
20px top padding to account for
iPhone status bar -->
< OnPlatform x:TypeArguments ="Thickness"
iOS ="0, 20, 0, 0"
Android ="0, 0, 0, 0"
WinPhone ="0, 0, 0, 0" />
</ ContentPage.Padding >
注意:此填充将添加到ContentPage
标记,而不是StackLayout
标记。从中检索到的代码