0

I'm having problem with not being able to stack two labels in a StackLayout and fit the content without a margin.

Expected result: enter image description here

Current output:

enter image description here

I have tried and set the VerticalOptions, Margin and Padding properties but it still contains the margin (the red background) as well as the second content is not touching the "ceiling" of it's StackLayout parent.

Current code:

<ViewCell>
    <StackLayout Orientation="Horizontal" VerticalOptions="Start">
    <StackLayout HorizontalOptions="Center" VerticalOptions="Center">
        <Image Source="summary.png"/>
    </StackLayout>
    <StackLayout Orientation="Vertical" VerticalOptions="Start" BackgroundColor="Red" Margin="0" Padding="0">
        <StackLayout BindingContext="{Binding Date}" VerticalOptions="Start" BackgroundColor="Beige" Margin="0" Padding="0">
          <Label Text="{Binding Text}" TextColor="{Binding Color}" VerticalOptions="Start"/>
        </StackLayout>
        <StackLayout BindingContext="{Binding Result}" VerticalOptions="Start" BackgroundColor="Blue" Margin="0" Padding="0">
          <Label Text="{Binding Text}" TextColor="{Binding Color}" FontSize="{Binding FontSize}" VerticalOptions="Start"/>
        </StackLayout>    
    </StackLayout>                                
    </StackLayout>
</ViewCell>
Westerlund.io
  • 2,743
  • 5
  • 30
  • 37
  • 3
    I'd start by removing all the unnecessary StackLayouts you have - I see at least three that only have a single child and aren't needed – Jason Feb 26 '19 at 19:01
  • 2
    I would clean up/simplify your view as Jason mentioned. Also, StackLayouts have a default `Spacing="6"` so try setting that to 0. – Nick Peppers Feb 26 '19 at 19:03

0 Answers0