【发布时间】:2018-01-28 06:11:06
【问题描述】:
我正在学习 Xamarin,我想在该图像上显示一个带有一些文本的图像作为背景...
就这样,我设法完成了,但文字显示在图像的左上角。
我希望将文本放置在图像的垂直中心,但要贴在图像的左侧。
到目前为止我的代码 XAML:
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="20*" ></RowDefinition>
<RowDefinition Height="65*"></RowDefinition>
<RowDefinition Height="15*"></RowDefinition>
</Grid.RowDefinitions>
<RelativeLayout Grid.Row="0">
<Image Source="login.png" Aspect="Fill" />
<Label Text="Bem vindo" TextColor="White" FontSize="22"></Label>
</RelativeLayout>
<Label Grid.Row="1" Text="linha 2" BackgroundColor="Coral"></Label>
<Button Grid.Row="2" Text="linha 3" BackgroundColor="DarkRed"></Button>
</Grid>
我试过verticalOptions之类的,但没有效果。
一种可行的方法是将 Maring 属性设置为标签,但这样一来,标签将仅以我正在测试的设备为中心。其他更小或更大的设备,标签可能(并且可能)放置在错误的位置。
有什么帮助吗?
【问题讨论】:
标签: xaml xamarin xamarin.forms