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

Wrong height for Label placed inside a Scrollview #13498

Closed
cat0363 opened this issue Feb 22, 2023 Discussed in #13494 · 14 comments · Fixed by #13554
Closed

Wrong height for Label placed inside a Scrollview #13498

cat0363 opened this issue Feb 22, 2023 Discussed in #13494 · 14 comments · Fixed by #13554
Labels
area-controls-label Label, Span area-controls-scrollview ScrollView fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149!

Comments

@cat0363
Copy link
Contributor

cat0363 commented Feb 22, 2023

Discussed in #13494

Originally posted by cat0363 February 22, 2023
Xamarin.Forms and .NET MAUI have different heights when placing a Label inside a ScrollView.
Below is the XAML for confirmation. (This is the result of running on Android.)

<Grid RowDefinitions="44,*" RowSpacing="0">
  <ScrollView Grid.Row="0" Orientation="Horizontal" BackgroundColor="Red">
    <Label Text="This is test." FontSize="18" HorizontalOptions="Start" VerticalOptions="Center" BackgroundColor="Yellow" />
  </ScrollView>
  <Grid Grid.Row="1" BackgroundColor="Blue" />
</Grid>

The execution result of Xamarin.Forms is as follows.
image

The execution result of .NET MAUI is as follows.
image

How can I get the same execution result as Xamarin.Forms?

@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Feb 22, 2023
@rachelkang rachelkang added the s/needs-info Issue needs more info from the author label Feb 22, 2023
@ghost
Copy link

ghost commented Feb 22, 2023

Hi @cat0363. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@rachelkang
Copy link
Member

Hi, @cat0363 - thanks for submitting this issue. Could you let us know what version of .NET you're on (have you tried the latest version yet? if not, could you give it a go?), and what platforms/versions you're seeing this issue on?

@cat0363
Copy link
Contributor Author

cat0363 commented Feb 22, 2023

@rachelkang, thank you for your reply.

I used .NET 7.0.2 The version of .NET MAUI is 6.0.552.
The platform is Android and the version is 11.0 (API 30).
I will try it later with .NET 7.0.3.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Feb 22, 2023
@PureWeen PureWeen added s/try-latest-version Please try to reproduce the potential issue on the latest public version and removed s/needs-attention Issue has more information and needs another look labels Feb 23, 2023
@ghost
Copy link

ghost commented Feb 23, 2023

Hi @cat0363. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@vhugogarcia
Copy link
Contributor

Hello @cat0363 ,

I solved this issue by just adding a fixed height to the label: HeightRequest="30". I don't think this is a .NET MAUI bug, per what I learned last week from the Xamarin.Forms migration to .NET MAUI Layouts, in .NET MAUI you need to specify values for layouts, in the past Xamarin.Forms was trying to calculate everything in real-time which was one of the things that make it not good in performance.

Please review this recent documentation the MS team shared with us 7 days ago. I found it really helpful and I personally learned from it. https://learn.microsoft.com/en-us/dotnet/maui/migration/layouts?view=net-maui-7.0

Note: I tested it on .NET MAUI 7.0.59
cc: @rachelkang

Screenshot_1677193603

@cat0363
Copy link
Contributor Author

cat0363 commented Feb 25, 2023

Hi, @rachelkang
I installed the latest Visual Studio 2021 Preview (17.6) and .NET 7 (7.0.3) to check if this issue is resolved.
Installing the latest Visual Studio 2021 Preview and .NET 7 did not resolve this issue. The results were the same.
If you need any additional information or anything else I should try, please let me know.

Hi, @vhugogarcia
Thank you for suggesting a solution to this issue.
When I first discovered this issue, I temporarily worked around it by specifying the Label's HeightRequest
as you suggested. For me, it was a workaround, not a solution, as the label's height changes depending
on the font you specify for it. I understand that explicitly specifying the size of the control is less computational
and better for performance. I would like it to work in .NET MAUI the same way it does in Xamarin.Forms,
as it's not ideal to explicitly specify a HeightRequest for each font you specify for a control.
Thank you for your help.

@cat0363 cat0363 closed this as completed Feb 25, 2023
@cat0363 cat0363 reopened this Feb 25, 2023
@cat0363
Copy link
Contributor Author

cat0363 commented Feb 25, 2023

Hi, @rachelkang
Earlier, when I was replying, I accidentally closed it.
I am sorry. Open again.

@ghost ghost closed this as completed Mar 4, 2023
@cat0363
Copy link
Contributor Author

cat0363 commented Mar 4, 2023

A msftbot changed the status of this issue to Closed. Is this change mechanical?
Or is it due to the solution by #13554?
I would like to know the reason why it became Closed.

@hartez
Copy link
Contributor

hartez commented Mar 6, 2023

Yeah, the robot closed it because of the "try latest version tag". It shouldn't have.
The issue should remain open until we have #13554 merged.

@hartez hartez reopened this Mar 6, 2023
@cat0363
Copy link
Contributor Author

cat0363 commented Mar 6, 2023

Hi, @hartez
Thank you for reopening and replying.
I hope that the solution(#13554) you provided will solve this Issue.

@ghost ghost closed this as completed Mar 14, 2023
@cat0363
Copy link
Contributor Author

cat0363 commented Mar 14, 2023

Hi, @hartez
This issue has been changed to closed status again by msftbot. Since this issue
has not been resolved, could you please open it again? Could you please let me
know if there is anything I should do to resolve this issue?

@hartez
Copy link
Contributor

hartez commented Mar 14, 2023

@cat0363 Sorry, I have no idea why the bot closed it this time. No action needed on your part, I'll re-open it.

@hartez hartez reopened this Mar 14, 2023
@cat0363
Copy link
Contributor Author

cat0363 commented Mar 15, 2023

@hartez , Thank you for reopening this issue.
I understand that I don't have to take any action.
I appreciate your daily work.

@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Mar 15, 2023
rmarinho pushed a commit that referenced this issue Mar 22, 2023
* Ensure an exact measure for the nested horizontal scrollview
Fixes #13498

* clean up and add comments

* Auto-format source code

* Add automated test

* Auto-format source code

* Remove unnecessary cast

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
@cat0363
Copy link
Contributor Author

cat0363 commented Mar 22, 2023

Thank you for your work leading up to the closure of this issue. \(^_^)/

@samhouts samhouts added the fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! label Apr 12, 2023
@samhouts samhouts added this to the .NET 8 milestone Apr 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 12, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-label Label, Span area-controls-scrollview ScrollView fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants