【发布时间】:2019-09-12 12:59:34
【问题描述】:
我正在尝试实现内容在背景上有图像的布局(位于左下角,垂直扩展 100%,水平扩展 60%)
整个内容被包裹在一个 AbsoluteLayout 中,主要内容是这个布局的一个子元素,由 StackLayout(以及里面的一些其他内容)组成。
Visual Studio (Visual Studio Community 2017) 中的预览器正确显示布局 - 图像位于内容下方,内容按预期放置在中间。但是,VS Emulator 和 Genymotion 都在内容上方显示图像。
我将代码修剪为尽可能可读(去掉了样式)
...
<Frame VerticalOptions="End" AbsoluteLayout.LayoutFlags="All" Margin="0" Padding="0" IsClippedToBounds="True" AbsoluteLayout.LayoutBounds="0,1,0.6,1">
<Image Source="Graphic_Anna.png" />
</Frame>
<!-- Start: Actual Page Content -->
<StackLayout VerticalOptions="Center" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" x:Name="ApplicationLayoutContentLevel">
<Label Text="This is some text in main content" />
</StackLayout>
<!-- End: Actual Page Content -->
</AbsoluteLayout>
</ContentPage.Content>
...
预期结果显示在此屏幕截图中(来自预览器):https://i.imgur.com/C8GBMSi.png
但是,两个模拟器中的结果似乎都是这样的:https://i.imgur.com/NvJFZan.png
很遗憾,我目前无法在实际的 Android 手机上测试该应用
【问题讨论】:
标签: xamarin xamarin.android absolutelayout