Skip to content

Commit

Permalink
fix: Fix support for TextBlock under Android 10
Browse files Browse the repository at this point in the history
Fixes #2016
  • Loading branch information
jeromelaban committed May 8, 2020
1 parent 7b05b51 commit fdc7327
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public partial class TextBlock : FrameworkElement

static TextBlock()
{
InitializeStaticLayoutInterop();
if ((int)Android.OS.Build.VERSION.SdkInt < 28)
{
InitializeStaticLayoutInterop();
}
}

/// <summary>
Expand Down Expand Up @@ -660,7 +663,9 @@ private void MakeLayout(int width, int maxLines = int.MaxValue)
}
}

Layout = UnoStaticLayoutBuilder.Build(
if ((int)Android.OS.Build.VERSION.SdkInt < 28)
{
Layout = UnoStaticLayoutBuilder.Build(
/*source:*/ _textFormatted,
/*paint: */ _paint,
/*outerwidth: */ width,
Expand All @@ -672,6 +677,21 @@ private void MakeLayout(int width, int maxLines = int.MaxValue)
/*ellipsizedWidth: */ width,
/*maxLines: */ maxLines
);
}
else
{
Layout = StaticLayout.Builder.Obtain(_textFormatted, 0, _textFormatted.Length(), _paint, width)
.SetLineSpacing(_addedSpacing = GetSpacingAdd(_paint), 1)
.SetMaxLines(maxLines)
.SetEllipsize(_ellipsize)
.SetEllipsizedWidth(width)
.SetAlignment(_layoutAlignment)
.SetIncludePad(true)
.Build();
}



}
}

Expand Down

0 comments on commit fdc7327

Please sign in to comment.