Closed bradencohen closed 7 months ago
This only seems to apply to Android 33+
The ChooseHeight
method seems to be getting called with a different "Top" value, which doesn't happen on Android 31.
Pretty ugly workaround to remove the LineHeight
from the Span
and put it on the outer Label:
private static void ConfigureLabelSpanLineHeightFix()
{
//
// This is a fix for labels that have spans with a LineHeight > 0.
// This tracks issue: https://github.com/dotnet/maui/issues/19592
//
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping( "FixFirstLevelSpans", ( handler, label ) =>
{
if ( label is Label rockLabel )
{
var spansWithLineHeight = rockLabel.FormattedText?.Spans?.Where( s => s.LineHeight > 0 );
var lineHeightBacking = 1d;
if ( spansWithLineHeight == null )
{
return;
}
foreach ( var span in spansWithLineHeight )
{
if ( span.LineHeight > lineHeightBacking )
{
lineHeightBacking = span.LineHeight;
}
span.LineHeight = 1;
}
rockLabel.LineHeight = lineHeightBacking;
}
} );
}
Verified this on Visual Studio Enterprise 17.9.0 Preview 3(8.0.3 and 7.0.101). Repro on Android 14.0-API34, not repro on Windows 11, iOS 17.0 and MacCatalyst with below Project: MauiRepros.zip
Description
When using a generic
Label
with aSpan
, theLineHeight
seems to be exponentially applied or something on Android.I understand that there are platform differences, but this behavior simply doesn't work and isn't usable. Is there something I'm misunderstanding or missing?
When the
LineHeight
is removed:Xamarin
In Xamarin, this works as intended:
Steps to Reproduce
Or
Link to public reproduction project repository
https://github.com/bradencohen/MauiRepros
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Nope, but any ideas would be super appreciated.
Relevant log output
No response