HtmlLabel an ultra lightweight implementation of converting html tags to Spans for an FormattedTextLabel. The idea is to enable formatting for localized strings in ressource-files of an app.
The Html Label supports adding HtmlText with the small list of supported features of the FormattedString in Xamarin Forms.
In the Test Appplication you can check the support of the Tags because there are only small Feeaturelist.
NuGet
The Control is available as NuGet Package MWX.XamForms.HtmlLabel here https://www.nuget.org/packages/MWX.XamForms.HtmlLabel/
HtmlText to Display
configures if newlines in the HTML-Text should stay there or not (default true -> ignore them).
simply add the XmlNamespace
xmlns:html="clr-namespace:MWX.XamForms.Controls;assembly=MWX.XamForms.HtmlLabel"
and then use it like a normal Label.
<html:HtmlLabel HtmlText="{Binding Text, Source={x:Reference htmlInput}}" />
Android | Windows | iOS |
---|---|---|
inline container for "style"-Attributes.
bold text
italic text
make a linebreak
configure the BackgroundColor as HexNumber (not supported by Xamarin.Forms.Label by UWP)
configure the Foreground-/Text-Color as HexNumber
supported values : bold, normal
supported values : italic, normal
configure the font family (Attention that is platform specific function)
configure the font size (ignoring any em,pt or px unit given)