Skip to content

Label not sized correctly on Android #27614

@jsuarezruiz

Description

@jsuarezruiz

PR REVERTED #30023

Description

Label not sized correctly on Android. The issue can be reproduced with the simple code below:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage">

    <ScrollView>
        <VerticalStackLayout>

           <Grid  VerticalOptions="Start"  BackgroundColor="Aquamarine">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Label Grid.Row="0" Grid.Column="0"
                    HorizontalOptions="Start"
                    Margin="5,5"
                    Text="Label and parent layout is behaving_differently_in_iOS"
                    BackgroundColor="Orchid"
                    TextColor="Black"
                    FontSize="20"/>

             </Grid>

        </VerticalStackLayout>
    </ScrollView>
</ContentPage>

We can see that the rendered Label, in case text is multi lines, is not identical on Android:

Image
Even can get a wrong result using different HorizotalOptions values (Start, Center, End):

Image

Steps to Reproduce

  1. Create a new MAUI app (targeting .NET 8 or 9) and use the XAML code above.
  2. Run the app on Android emulator and iOS simulator. You should see the Label is rendered differently on Android and iOS.

Link to public reproduction project repository

No response

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-labelLabel, Spanarea-layoutStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been reviewedt/bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions