Xamarin.forms: [Bug] Android frame with undeclared padding since XF4.4

Created on 27 Feb 2020  路  8Comments  路  Source: xamarin/Xamarin.Forms

Description

I have the following xaml file containing a stacklayout with a frame:

<StackLayout Margin="8">
    <Frame HasShadow="True" BackgroundColor="Gray" HorizontalOptions="FillAndExpand">
        <Grid RowSpacing="1" ColumnSpacing="1" VerticalOptions="FillAndExpand">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition >
                    <RowDefinition.Height>
                        <OnPlatform x:TypeArguments="GridLength">
                            <On Platform="iOS" Value="24" />
                            <On Platform="Android" Value="60" />
                            <On Platform="UWP" Value="60" />
                        </OnPlatform>
                        <!--<OnPlatform x:TypeArguments="GridLength" iOS="24" Android="60" WinP hone="60" />-->
                    </RowDefinition.Height>
                </RowDefinition>
                <RowDefinition Height="Auto" >
                    <!--<RowDefinition.Height>
                                    <OnPlatform x:TypeArguments="GridLength" iOS="24" Android="35" WinPh one="20" />
                                </RowDefinition.Height>-->
                </RowDefinition>
                <RowDefinition Height="0.3"/>
            </Grid.RowDefinitions>

            <!--4 linhas-->
            <Label Text="NomeCliente" HorizontalTextAlignment="Start" VerticalTextAlignment="Start" FontSize="Medium" Margin="-10"/>
            <BoxView HorizontalOptions="Fill" VerticalOptions="Start" Grid.Row="3" Color="Green" Margin="-20" />

            <BoxView VerticalOptions="Fill" HorizontalOptions="Start" WidthRequest="5" Color="Blue" Margin="-20" Grid.RowSpan="3" />
            <!--<BoxView VerticalOptions="Fill" HorizontalOptions="Start" Grid.Row="1" WidthRequest="5" Color="{StaticResource CorDestaque}" Margin="-20" />
                                <BoxView VerticalOptions="Fill" HorizontalOptions="Start" Grid.Row="2" WidthRequest="5" Color="{StaticResource CorDestaque}" Margin="-20" />
                                <BoxView VerticalOptions="Fill" HorizontalOptions="Start" Grid.Row="3" WidthRequest="5" Color="{StaticResource CorDestaque}" Margin="-20" />-->

            <Grid Grid.Row="1" HorizontalOptions="Start">
                <Grid.ColumnDefinitions >
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Label Text="DescricaoNumNF" VerticalTextAlignment="Center" HorizontalTextAlignment="Start"/>
                <Label Text="TipoRep" HorizontalTextAlignment="Center" Grid.Column="1" VerticalTextAlignment="Center"/>

                <!--ICONE DA FILIAL-->
                <Label Grid.Column="2" VerticalTextAlignment="Center" >
                    <Label.FormattedText >
                        <FormattedString>
                            <Span Text="IC" FontSize="15" TextColor="Black"/>
                            <Span Text="   "/>
                            <Span Text="FilialDest"/>
                        </FormattedString>
                    </Label.FormattedText>
                </Label>
            </Grid>

            <Grid Grid.Row="1" HorizontalOptions="End">
                <!--ICONES: 1= CATALOGO; 2=STATUS ENVIO; 3= ON/OFF-->
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <!--ICONE DO CATALOGO-->
                <Label Text="&#xf02d;"  FontSize="15" TextColor="Brown" HorizontalTextAlignment="End" VerticalTextAlignment="Center" IsVisible="False"/>

                <!--ICONE DO STATUS DESTINO-->
                <Label Text="IC>" Grid.Column="1" FontSize="15" TextColor="Red" HorizontalTextAlignment="End" VerticalTextAlignment="Center"/>

                <!--ICONE ON/OFF-->
                <Label Grid.Column="2" VerticalTextAlignment="Center" >
                    <Label.FormattedText >
                        <FormattedString>
                            <Span Text="IC" FontSize="15" TextColor="Yellow"/>
                            <Span Text=" "/>
                            <Span Text="sla"/>
                        </FormattedString>
                    </Label.FormattedText>
                </Label>
            </Grid>

            <Label Grid.Row="2" VerticalOptions="EndAndExpand" HorizontalTextAlignment="End" VerticalTextAlignment="End" Margin="-8">
                <Label.FormattedText >
                    <FormattedString>
                        <Span Text="IC" TextColor="Black" FontSize="15" />
                        <Span Text=" "/>
                        <Span Text="27/2/2020"/>
                    </FormattedString>
                </Label.FormattedText>
            </Label>

            <Label Text="DescPedido" Grid.Row="2" VerticalTextAlignment="End" HorizontalTextAlignment="Start" TextColor="Purple" Margin="-10" />
        </Grid>
    </Frame>
</StackLayout>

The frame is OK in xamarin forms 4.3, but since 4.4 it is broken with a strange padding. I've tried to set the frame padding to 0 but nothing changes. I dont know what I'm doing wrong. Can you help me? I don't know if it is a Bug or a bad code.

Steps to Reproduce

  1. Run the reproduction project in XF 4.3
  2. Update the project to XF 4.5
  3. Run

Expected Behavior

Frame layout keep the same

Actual Behavior

Frame layout looks broken because of a padding

Basic Information

  • Version with issue: XF4.4+
  • Last known good version: XF4.3
  • Platform Target Frameworks:

    • Android: 5.0+

Screenshots

Frame in Forms 4.3
Screenshot_1582806452

Frame in Forms 4.5
Screenshot_1582806752

Reproduction Link

FrameBug.zip

Workaround

4.4.0 frame layout high regression Android bug

All 8 comments

If it helps in UWP it works fine

I have the same problem

Hi people,

This error still hapens with XF 4.6

Waiting for the fix

Hi @samhouts,

Can you add the 4.6.0 label/milestone to this issue ?
This issue in only on Triage project and 4.4.0 was closed.

I'm locked on XF 4.3 because this bug.

@transis2 That label just lets us keep track of when the regression started. We'll definitely merge the fix into the next available release. Thanks!

Thank you @samhouts

g for the fix

It麓s hapening to mee too. Waiting for some solution;

Any news on this ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Papirosnik picture Papirosnik  路  3Comments

MartinWegner picture MartinWegner  路  3Comments

jgold6 picture jgold6  路  3Comments

EmilAlipiev picture EmilAlipiev  路  3Comments

deakjahn picture deakjahn  路  3Comments