radimitrov / CSharpShellApp

77 stars 18 forks source link

.NET MAUI UI Bug #342

Closed PeterKaa1 closed 5 months ago

PeterKaa1 commented 7 months ago

If i create an application in .NET MAUI which has 3 buttons below each other in the center of the page and i run it in the IDE the buttons look fine but if i export the APK and launch it the buttons do not have space around them (left & right side, above and below) like if they were glued to each other.

https://www.mediafire.com/file/fiwggjia2sqlzhd/apk.jpg/file

https://www.mediafire.com/file/cwkyhxka0tydf33/ide.jpg/file

It is super annoying.

radimitrov commented 7 months ago

I haven't yet however will check this out soon since I just finished successfully building the C# Shell solution for .NET 8.

PeterKaa1 commented 7 months ago

I haven't yet however will check this out soon since I just finished successfully building the C# Shell solution for .NET 8.

I wonder what it is caused by and if you will be able to fix it.

radimitrov commented 7 months ago

The problem now exists in the .NET 8 update of the IDE as well. This suggests it is some conflict issue with either MAUI or Material dependencies. Very little I can do about that currently. Already tried all versions of Xamarin.Google.Android.Material allowed by Microsoft.Maui.Controls. Not sure if this is a C# Shell issue or MAUI packages issue yet.

A workaround like this can be implemented (not sure about the values yet): Edit Resources/Styles/Styles.xaml to include <Setter Property="Margin" Value="0,3,0,3"/> inside the <Style TargetType="Button">

If I still haven't managed to replicate this issue with a test project until the end of this month, then this workaround will be become part of the app so it can be updated since this seems to be the only issue so far.

PeterKaa1 commented 7 months ago

The problem now exists in the .NET 8 update of the IDE as well. This suggests it is some conflict issue with either MAUI or Material dependencies. Very little I can do about that currently. Already tried all versions of Xamarin.Google.Android.Material allowed by Microsoft.Maui.Controls. Not sure if this is a C# Shell issue or MAUI packages issue yet.

A workaround like this can be implemented (not sure about the values yet): Edit Resources/Styles/Styles.xaml to include <Setter Property="Margin" Value="0,3,0,3"/> inside the <Style TargetType="Button">

If I still haven't managed to replicate this issue with a test project until the end of this month, then this workaround will be become part of the app so it can be updated since this seems to be the only issue so far.

Alright, thanks. Keep me updated, please.

radimitrov commented 7 months ago

After taking a deeper look at this it looks like the .NET 8 C# Shell build fixes the actual bug, probably via the ability to finally have consistent Material package versions.

The bug was actually in the IDE as by default a VerticalStackLayout has 0 Spacing. I'm not sure when that changed, but it is so in a default MAUI project in VS.

If you want VerticalStackLayout spacing by default you can edit the Resources/Styles.xaml file to add a Setter, similar to what I mentioned before.

PeterKaa1 commented 7 months ago

After taking a deeper look at this it looks like the .NET 8 C# Shell build fixes the actual bug, probably via the ability to finally have consistent Material package versions.

The bug was actually in the IDE as by default a VerticalStackLayout has 0 Spacing. I'm not sure when that changed, but it is so in a default MAUI project in VS.

If you want VerticalStackLayout spacing by default you can edit the Resources/Styles.xaml file to add a Setter, similar to what I mentioned before.

Alright, thanks.