Xaml relative layout different between IOs and Android

Hello i have a problem and i don't know how to fix it.
I've the Xuni Calendar and for each cell of the day i've created this xaml:

<RelativeLayout>
                                            <BoxView  x:Name="redBox" Color="{Binding coloreSfondo}"
                                                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
                                                    Property=Height,Factor=.1,Constant=0}"
                                                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
                                                   Property=Width,Factor=.1,Constant=0}"
                                                RelativeLayout.WidthConstraint="{ConstraintExpression
                                                    Type=RelativeToParent,Property=Width,Factor=.8,Constant=0}"
                                                RelativeLayout.HeightConstraint="{ConstraintExpression
                                                    Type=RelativeToParent,Property=Height,Factor=.8,Constant=0}" />
                                                    <StackLayout 
                                                        RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
                                                    Property=Height,Factor=.4,Constant=0}"
                                                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
                                                   Property=Width,Factor=.1,Constant=0}"
                                                RelativeLayout.WidthConstraint="{ConstraintExpression
                                                    Type=RelativeToParent,Property=Width,Factor=.8,Constant=0}"
                                                RelativeLayout.HeightConstraint="{ConstraintExpression
                                                    Type=RelativeToParent,Property=Height,Factor=.2,Constant=0}" 

                                                        >
                                                        <Label TextColor="{Binding coloreTesto}" Text="{Binding Day}" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" FontSize="16"/>
                                                    </StackLayout>
                                        </RelativeLayout>

in IOs it works and create the box centered and big enaugh but in Android it creates a small box in width it's correct but in height no. What am i doing wrong?
Thank you

Answers

  • SirAndriySirAndriy USMember ✭✭✭
    edited March 2017

    You can try use OnPlatform:

    <Box.WidthRequest>
              <OnPlatform x:TypeArguments="x:Double"
                                  iOS="20"
                                  Android="22" />
    </Box.WidthRequest>
    
  • but my calendar it's dynamic in height and width so each cell generates it's height and width so the layout must be relative or propotional to the parent..

Sign In or Register to comment.