Forum Xamarin.Forms

AbsoluteLayout - How to combine Proportional layout with AutoSize?

BlueRajaBlueRaja USMember ✭✭

I'm trying to position a control at the bottom of the screen (on top of all other controls), with the width of the full-screen but using the control's natural height. Based on the documentation and comments on this forum, I should be using "0,1,1,AutoSize" for the layout:

<AbsoluteLayout>
  ...
  <myControl AbsoluteLayout.LayoutBounds="0,1,1,AutoSize" AbsoluteLayout.LayoutFlags="All"/>
</AbsoluteLayout>

However, this doesn't work - the control doesn't appear at all. If I change "AutoSize" to, say, "0.2", then it works, but then the control height is not autosized.

How do I get an absolutely-positioned, autosized control at the bottom of the screen?

Best Answer

  • BlueRajaBlueRaja USMember ✭✭
    edited June 14 Accepted Answer

    I finally figured it out. You need to make the height non-proportional, which you can do by combining flags using ","

    <myControl AbsoluteLayout.LayoutBounds="0,1,1,AutoSize" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional"/>
    

    It's kind of silly that the default behavior is "ignore AutoSize completely"

Answers

  • BlueRajaBlueRaja USMember ✭✭
    edited June 14 Accepted Answer

    I finally figured it out. You need to make the height non-proportional, which you can do by combining flags using ","

    <myControl AbsoluteLayout.LayoutBounds="0,1,1,AutoSize" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional"/>
    

    It's kind of silly that the default behavior is "ignore AutoSize completely"

Sign In or Register to comment.