Error on views alignment in StackLayout

romainb78romainb78 FRMember

Hello,

In Xamarin.Forms, I don't know how to start vertically alignment without space the views in the a Stacklayout.

Here is my code:

    ...
        <ContentPage.Content>
            <AbsoluteLayout>

                <StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                             AbsoluteLayout.LayoutFlags="All"
                             VerticalOptions="StartAndExpand"
                             Padding="10, 10, 10, 10">

                    <TableView>
                        <TableRoot>
                            <TableSection>
    ...
                            </TableSection>

                        </TableRoot>
                    </TableView>

                    <Button Clicked="OnValidate"
                            Text="Validate"
                            Style="{StaticResource ValiderButtonStyle}" />

                </StackLayout>

                <StackLayout x:Name="WSActivityIndicator"
                             Style="{StaticResource LoadingStackLayoutStyle}">
                    <ActivityIndicator Style="{StaticResource LoadingActivityIndicatorStyle}" />
                    <Label Style="{StaticResource LoadingLabelStyle}" />
                </StackLayout>

            </AbsoluteLayout>
        </ContentPage.Content>

    </ContentPage>

As you can see, the TableView isn't vertically aligned at the top and the Button is vertically aligned at the bottom instead of being at the bottom of the TableView.

PS: I had to hide the labels on the image inserted for reasons of confidentiality

Answers

  • gdkgdk INMember ✭✭✭

    Hi romain, Have you tried with set spacing of stacklayout set to be zero

  • romainb78romainb78 FRMember
    edited May 2017

    I tried to set Spacing to 0 but there is no difference

                <StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                             AbsoluteLayout.LayoutFlags="All"
                             VerticalOptions="StartAndExpand"
                             Padding="10, 10, 10, 10"
                             Spacing="0">
    

    Same without AbsoluteLayout properties

                <StackLayout VerticalOptions="StartAndExpand"
                             Padding="10, 10, 10, 10"
                             Spacing="0">
    

    Any idea?

Sign In or Register to comment.