image - Xamarin Forms 覆盖图像作为背景并在不同方向放置标签
问题描述
我想做如下图所示的事情。我尝试了绝对布局,但一旦进入景观,它就会改变一切。一切都再次到位。
最终结果将如下图所示(精神-票证部分)
到目前为止我所拥有的
<StackLayout BackgroundColor="#F0F0F0">
<Grid Margin="10" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.ColumnSpan="2" Text="Please review your reservation below" LineBreakMode="WordWrap"/>
<StackLayout Grid.Row="1" Grid.ColumnSpan="2" >
<AbsoluteLayout>
<Image>
<AbsoluteLayout.LayoutBounds>
<OnPlatform x:TypeArguments="Rectangle">
<On Platform="Android" Value=".5,.5,1.0,1.8" />
<On Platform="iOS" Value=".5,.10,1.8,1" />
</OnPlatform>
</AbsoluteLayout.LayoutBounds>
<AbsoluteLayout.LayoutFlags>
<OnPlatform x:TypeArguments="AbsoluteLayoutFlags">
<On Platform="Android" Value="All" />
<On Platform="iOS" Value="All" />
</OnPlatform>
</AbsoluteLayout.LayoutFlags>
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource">
<On Platform="Android" Value="ticketone.png" />
<On Platform="iOS" Value="ticket.png" />
</OnPlatform>
</Image.Source>
</Image>
<Label AbsoluteLayout.LayoutBounds="0.1,99,.56,50" AbsoluteLayout.LayoutFlags="XProportional,WidthProportional" Text="ROOMSHFBHE GFDJHBCSJSJJ HJSDHSJ no snonnoj" TextColor="White" FontSize="20" FontAttributes="Bold" LineBreakMode="WordWrap" />
</AbsoluteLayout>
我在风景中得到了什么
解决方案
无论方向如何,这都会创建居中的顶部标签
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" VerticalTextAlignment="Center"
HorizontalOptions="FillAndExpand" BackgroundColor="Black"
TextColor="White" HorizontalTextAlignment="Center" Text="center" />
</Grid>
推荐阅读
- javascript - 关于照片未显示在我的画廊中的几个问题
- python - While 循环进行 API 调用,直到满足条件
- c# - 以编程方式在 Unity 上绑定脚本属性(编辑模式不在运行时)
- python-3.x - 无服务器 - 找不到好的绑定路径格式
- javascript - Firefox 扩展:如何从 popup.js 获取当前打开的选项卡的文档?
- azure - 我们如何在 dbfs/filestore 上保存或上传 .py 文件
- sql - CURRENT_TIMESTAMP 和 CURRENT_DATE 之间的差异
- java - 如何将@Qualifier 与服务和存储库一起使用
- python - 减去截断的数字:结果没有被截断?
- android - 是否可以实现像延迟这样的运算符,但也会延迟错误?