有没有办法在 XAML Xamarin 中指定多个 LayoutFlags?

Is there a way to specify multiple LayoutFlags in XAML Xamarin?

我有一个标签设置为相对定位和自动大小,如下所示

<Style TargetType="Label">
    <Setter Property="BackgroundColor" Value="Transparent" />
    //Something like below?            
    <Setter Property="AbsoluteLayout.LayoutFlags" Value="PositionProportional | SizeProportional" />
</Style>

....

<Label Text="0" AbsoluteLayout.LayoutBounds="0.5, 0.00499999999999998, AutoSize, AutoSize"/>

有没有办法在 XAML 中指定多个 LayoutFlags?

因为我 运行 在具有更高分辨率的设备上的代码,标签的相对位置是正确的,但标签的大小(字体)没有增加,尽管它被设置为 AutoSize。我想我还需要为标签指定 LayoutFlag,即 SizeProportional 和 PositionProportional。但是如何在XAML中做到呢?目前,当设备旋转到横向时,字体不会调整大小。

如您所见: AbsoluteLayout on Xamarin Documentation

Flags are also specified in the declaration of views in the layout using the AbsoluteLayout.LayoutFlags property. Note that flags can be combined in XAML using a comma-separated list.

所以在你的情况下,没有意义,因为你想使用 All 值(同时使用 Positionning 和 Sizing proportionnaly)。 但我不得不使用这样的东西,它工作得很好:

<StackLayout AbsoluteLayout.LayoutBounds="0,1,1,100"
                 AbsoluteLayout.LayoutFlags="XProportional,YProportional,WidthProportional">
</StackLayout>

希望它能帮助那些用谷歌搜索并找到它的人 post :)