1

I'm using AbsoluteLayout to render my view, essentially I have a map filled view and a button aligned to the bottom of the AbsoluteLayout

AbsoluteLayout (fill)
|--View (fill)
|--Button (bottom, full-width, 200 height)

Here is my code which uses proportional values to define the layout:

<AbsoluteLayout 
     VerticalOptions="FillAndExpand"
     HorizontalOptions="FillAndExpand">
            <maps:Map 
                AbsoluteLayout.LayoutBounds="0,0,1,1"
                AbsoluteLayout.LayoutFlags="All" /> 
             <Button
                AbsoluteLayout.LayoutBounds="0.5,1,0.5,0.15"
                AbsoluteLayout.LayoutFlags="All" />
             // ... other controls ... //
</AbsoluteLayout>

It works perfectly fine except the fact that my button has a dynamic height (proportional to the parent height). I want to keep is static as long as I have other styles which makes it ugly whenever height is dynamic (e.g. BorderRadius).

I tried to use absolute values for the button but now I'm constrained to have both height and width defined in absolute values while I want only the height to be defined in absolute values and width continue to take whole parent width span.

mrisek
  • 659
  • 1
  • 8
  • 25
Mando
  • 11,414
  • 17
  • 86
  • 167
  • 1
    Is the goal to have both position and width be proportional, and height (only) be absolute? If so, you can specify a comma-separated list on the button: AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional". – DavidS Jan 15 '18 at 05:50

1 Answers1

5

In AbsoluteLayout we can determine which four properties to be proportional or absolute(static) by setting AbsoluteLayout's LayoutFlagsAs. So as @DavidS mentioned, you can set Button's height as static this way (say 50):

<AbsoluteLayout 
   VerticalOptions="FillAndExpand"
   HorizontalOptions="FillAndExpand">
            <maps:Map 
                AbsoluteLayout.LayoutBounds="0,0,1,1"
                AbsoluteLayout.LayoutFlags="All" /> 
             <Button
                AbsoluteLayout.LayoutBounds="0.5,1,0.5,50"
                AbsoluteLayout.LayoutFlags="PositionProportional,WidthPropor‌​tional" />
             // ... other controls ... //
</AbsoluteLayout>
VahidShir
  • 2,066
  • 2
  • 17
  • 27