我想使用仅使用 xaml 使用 Xamarin 表单的相对布局将 Stacklayout 放置在图像顶部的底部。xaml 看起来就像这样。
<RelativeLayout>
<Image />
<StackLayout Orientation="Horizontal">
<Label Text="Dark Mode" />
<Switch />
<Label Text="Light Mode" />
</StackLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的 StackLayout 应该有什么 X 和 Y 约束,以便它位于图像的顶部和底部。还添加了一个描述我期望的结果的图像。
我确实尝试将RelativeLayout.XConstraints和RelativeLayout.YConstraints同时提供给图像和stacklayout,但无法弄清楚使用什么值来获得所需的结果。