-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[9.0, GA, Android] An Android Button Minimum Size is Enforced #25903
Comments
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.
|
@spadapet does that right a bell? |
@jfversluis that does ring a bell. Although the fix for the following bug was only supposed to have an effect if Minimum/MaximumHeightRequest were set along with HeightRequest: Neither of those are set in the example, but maybe they are coming from a Style? |
I think the min widths and heights are set in the styles.xaml? Maybe remove it there? |
I'm using .NET 9: And I couldn't reproduce the issue with a new MAUI app from template. Here's what I tried (along with adding a Button of height 44, with the rendered height set as the text in the Buttons): So I'm probably missing something from what @david-maw had. Please provide a small sample app if I'm missing something. |
Thanks @spadapet your speculation about styles was correct, my Styles.xaml was generated by VS and contains under the Button style: <Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/> I just generated a new .NET 9 MAUI project in VS and those lines are present there too. How did you generate your app? |
Oops, sorry @mattleibow I misattributed your styles speculation (which was correct). |
@david-maw I'm using Visual Studio 2022 version 17.12. I simply created a new project from MAUI template: Then in MainPage.xaml I replaced the contents of the ContentPage with: <HorizontalStackLayout BackgroundColor="Yellow">
<Button BackgroundColor="Green" HeightRequest="30" Text="{Binding Height, Source={x:RelativeSource Self}}" />
<Rectangle Background="Red" HeightRequest="30" WidthRequest="30"/>
<Button BackgroundColor="Green" HeightRequest="44" Text="{Binding Height, Source={x:RelativeSource Self}}" />
</HorizontalStackLayout> In Styles.xaml it does have a So this behavior I'm seeing is exactly the bug I made a fix for: Now I see my PR for that bug was merged into .NET 9 SR1, so it's not part of the .NET 9 GA release. Maybe the SR1 release will fix this bug? |
Weirder and weirder, you see the So something fixed the bug (and thus changed the behavior) in the GA release, but it did it for me and not for you. I repeated your test and it performed exactly as you described, then I repeated my original test which was to stick the XAML into an existing test app and the problem reappeared. I'll spend some time figuring out the difference and get back to you. |
Thanks for testing @kevinxufei. It verifies that MAUI 9.0.10 does fix the issue where MinimumHeightRequest=44 from the Style was being ignored. It's definitely a change from RC and GA because now HeightRequest less than 44 won't work unless you change the default Style for Button. |
Which is weird @spadapet, since your fix didn't go into the GA release and, as you noted (and I verified), it does not fail in the GA release with a new MAUI app from the template. The explanation for that seems to be that a new MAUI app from the template uses Microsoft.Maui.Controls 9.0.0. All you have to do is switch to 9.0.10 and the changed behavior appears. I thought 9.0.10 was the GA release, but it seems to be the SR1 with your change in it? I dont think it matters now we understand what's going on but I was able to reproduce the problem in an App migrated from .NET 8, because it uses Microsoft.Maui.Controls 9.0.10 we now know. That repo is https://github.com/david-maw/SimpleCollectionView-ButtonHeight.git. I used a version of the XAML you used and in .NET 8 it showed: But in .NET 9 it honored the minimum height request from the styles and showed this: So, all appears to be clear, the only question is what to do about the breaking change, which is no longer a problem for me now I know what's going on, but might still surprise others. |
I'm not sure about exact GA vs SR1 version numbers for MAUI. Maybe they can differ compared to .NET 9. Here's the exact commit: |
What seems to have happened is 9.0.0 was shipped and is what a new MAUI app uses by default, but 9.0.10 is also available. Whether 9.0.10 was available at the time of GA I don't know, that's history now :-) |
So I just want to check up on this... The issue is fixed now with at least 9.0.10 and the min height is respected. @davidortinau maybe this is something that we can put in the changes doc from net8 to net9. Sure, 9.0.0 also has the old behavior, but we can say it is as designed for net9. And then try get VS to use 9.0.10 ASAP. For this issue specifically, is there more action needed? |
I'm assuming there isn't a question, just an over-zealous bot? |
Description
In RC2 you could set an Android Button height or width to numbers less than 44, now the limit is 44.
Steps to Reproduce
This XAML snippet shows it
On RC2 Android the button and rectangle will be the same height, on GA Android (or on GA or RC2 Windows) the button will be height 44, visibly larger than the rectangle.
It looks like this was a result of #25163 which, on the face of it, is a reasonable observation, but fixing it creates surprises for anyone who (like me) was inadvertently relying on the fact that on Android the default minimum height was ignored. I'd naively assumed it was something very small without checking. At the very least it's worth documenting as a breaking change because it has worked like this for a long time.
Link to public reproduction project repository
No response
Version with bug
9.0.0 GA
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
9.0.0-rc.2.24503.2
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: