Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label not sized correctly on Android #27614

Open
jsuarezruiz opened this issue Feb 6, 2025 · 3 comments
Open

Label not sized correctly on Android #27614

jsuarezruiz opened this issue Feb 6, 2025 · 3 comments
Labels
area-controls-label Label, Span area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/android 🤖 s/triaged Issue has been reviewed t/bug Something isn't working

Comments

@jsuarezruiz
Copy link
Contributor

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

@jsuarezruiz jsuarezruiz added the t/bug Something isn't working label Feb 6, 2025
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/android 🤖 area-controls-label Label, Span labels Feb 6, 2025
@jsuarezruiz jsuarezruiz added this to the .NET 9 Servicing milestone Feb 6, 2025
@dotnet-policy-service dotnet-policy-service bot added the s/triaged Issue has been reviewed label Feb 6, 2025
@kubaflo
Copy link
Contributor

kubaflo commented Feb 6, 2025

Hi @jsuarezruiz it looks like a native behavior. What do you think?

Image

@bricefriha
Copy link

bricefriha commented Feb 7, 2025

@kubaflo

Have you tried to set layout_width to fill_parent?

To my understanding, it should work this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-label Label, Span area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/android 🤖 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants