I Have a label set to relative positioning and auto size as shown below
<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"/>
Is there a way to specify multiple LayoutFlags in XAML?
As I run the code on devices with higher resolution the relative position of the label is correct but the size (font) of the label does not increase, although it is set to AutoSize. I figured I also needed to specify a LayoutFlag for the Label that is SizeProportional as well as PositionProportional. But how to do it in XAML? Currently the fonts don't resize when the device is rotated to landscape orientation.
An AbsoluteLayout can position and size children using proportional values. This is achieved by adding children to the Children collection of the AbsoluteLayout , and by setting the AbsoluteLayout. LayoutBounds attached property on each child to proportional position and/or size values in the range 0-1.
Grid. A Grid is used for displaying elements in rows and columns, which can have proportional or absolute sizes.
As you can read here : 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.
So in your case, there is no point since you want to use the All
value (using both Positionning and Sizing proportionnaly).
But I had to use something like this and it works just fine :
<StackLayout AbsoluteLayout.LayoutBounds="0,1,1,100"
AbsoluteLayout.LayoutFlags="XProportional,YProportional,WidthProportional">
</StackLayout>
Hope it will help people like who googled it and found this post :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With