【发布时间】:2017-08-12 16:41:47
【问题描述】:
我想使用仅使用 xaml 的 Xamarin 表单使用相对布局将 Stacklayout 放置在图像顶部的底部。 xaml 看起来很像这样。
<RelativeLayout>
<Image />
<StackLayout Orientation="Horizontal">
<Label Text="Dark Mode" />
<Switch />
<Label Text="Light Mode" />
</StackLayout>
</RelativeLayout>
我的 StackLayout 应该有什么 X 和 Y 约束,以便它位于图像的顶部和底部。还添加了一个描述我期望结果的图像。
我确实尝试将 RelativeLayout.XConstraints 和 RelativeLayout.YConstraints 赋予图像和 stacklayout ,但无法弄清楚使用什么值来获取想要的结果。
【问题讨论】:
-
你可以用
Grid代替RelativeLayout。 -
@EgorGromadskiy 我确实已经尝试过这种方法,但是即使 Aspect 设置为 AspectFill,我的图像也不会在网格内拉伸。
标签: xaml xamarin xamarin.forms uwp-xaml xamarin.uwp