maui icon indicating copy to clipboard operation
maui copied to clipboard

Unexpected result with MaximumWidthRequest on a Label on Android

Open pekspro opened this issue 3 years ago • 2 comments

Description

MaximumWidthRequest on a Label on Android sometimes gives unexpected result. If you use in combined with HorisontalOptions=Fill you could get extra empty lines, and the text is wider than the maximum width. If you have value than is larger than the screen the Label will stretch outside the screen.

image

Compare this with Windows which I think behaves correctly: image

Steps to Reproduce

  1. Create a new MAUI app.
  2. Update MainPage.xaml width this:
<ScrollView>
    <VerticalStackLayout Padding="8">
        <Label Text="MaximumWidthRequest: 200, HorizontalOptions: Start" />

        <Rectangle MinimumHeightRequest="4" WidthRequest="200" HorizontalOptions="Start" BackgroundColor="#FF99FF" />

        <Label 
            Text="one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five"
            BackgroundColor="#9999FF"
            HorizontalOptions="Start"
            MaximumWidthRequest="200"
            />

        <Label Text="MaximumWidthRequest: 200, HorizontalOptions: Fill" Margin="0,30,0,0"  />

        <Label 
            Text="one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five"
            BackgroundColor="#9999FF"
            HorizontalOptions="Fill"
            MaximumWidthRequest="200"
            />

        <Label Text="MaximumWidthRequest: 2000, HorizontalOptions: Start" Margin="0,30,0,0" />

        <Label 
            Text="one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five"
            BackgroundColor="#9999FF"
            HorizontalOptions="Start"
            MaximumWidthRequest="2000"
            />

    </VerticalStackLayout>
</ScrollView>
  1. Run the application on Android.

Link to public reproduction project repository

https://github.com/pekspro/MauiIssues/tree/10552_Unexpected_result_with_MaximumWidthRequest

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Windows 10.0.17763.0, Android 11

Did you find any workaround?

No response

Relevant log output

No response

pekspro avatar Oct 07 '22 19:10 pekspro

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Oct 07 '22 21:10 ghost

I've updated sample application to .NET 7. The same issue remains.

pekspro avatar Nov 11 '22 17:11 pekspro

I got some problems with MaximumWidthRequest too.

I have a maximum width of 650 on my <Grid> (inside a <ScrollView>) because I don't want my <Entry> to fill all the screen because it looks ugly. I don't get why it's ok on tablet but on phone, it seems like the maximum width is taken as the requestWidth.

My problem is that on Android Phone, it feels like WidthRequest takes MaximumWidthRequest. My content goes out of the screen.

See the screenshot below

image

If I remove the maximum width, here is how it looks (and how it should looks with MaximWidthRequest) image

The problem still exist on the latest .NET 7 released the 8th november 2022

nk54 avatar Nov 15 '22 10:11 nk54

Verified this on Visual Studio Enterprise 17.7.0 Preview 1.0. Repro on Android 13.0-API33 and iOS 16.4 with below Project: 10552.zip

Android: image

iOS: image

XamlTest avatar Jun 01 '23 02:06 XamlTest