Search code examples
c#xamarinabsolutelayout

How to set AbsoluteLayout.LayoutBounds by platform?


I'm using an absolute layout in my application and I want, for each element in the layout, a specific position and size depending the platform.

I find an other question where it was said that to use

<Label.AbsoluteLayout.LayoutBounds>

But it my case, the AbsoluteLayout property doesn't exist if I write it between <...>

So, It is possible to set the property LayoutBounds by platform ?

I'm using Xamarin 4.4.

Thanks for your help


Solution

  • AbsoluteLayout.LayoutBounds="{OnPlatform Android='0,0,1,1', iOS='0,0,.5,.5'}"

    I believe that should work, but i haven't tested it. You just need to use OnPlatform and provide the desired values for each platform you want to cover.

    Edit: Just tested this. It works.