Xam.Plugin.HtmlLabel
3.0.1.6
See the version list below for details.
dotnet add package Xam.Plugin.HtmlLabel --version 3.0.1.6
NuGet\Install-Package Xam.Plugin.HtmlLabel -Version 3.0.1.6
<PackageReference Include="Xam.Plugin.HtmlLabel" Version="3.0.1.6" />
paket add Xam.Plugin.HtmlLabel --version 3.0.1.6
#r "nuget: Xam.Plugin.HtmlLabel, 3.0.1.6"
// Install Xam.Plugin.HtmlLabel as a Cake Addin #addin nuget:?package=Xam.Plugin.HtmlLabel&version=3.0.1.6 // Install Xam.Plugin.HtmlLabel as a Cake Tool #tool nuget:?package=Xam.Plugin.HtmlLabel&version=3.0.1.6
HTML Label Plugin for Xamarin.Forms
Use this Xamarin.Forms plugin to display HTML content into a label.
** MID YEAR UPDATE **
- Xamarin.Forms 3.0
- IsHtml and RemoveHtmlTags properties removed
- HtmlAgilityPack dependency removed
- Navigating and Navitated events added when users tap on links
- Namespace and assembly name changed
Setup
- Available on NuGet: https://www.nuget.org/packages/Xam.Plugin.HtmlLabel
- Install it in every Xamarin.Forms project.
- iOS: AppDelegate.cs
HtmlLabelRenderer.Initialize(); global::Xamarin.Forms.Forms.Init();
- Android: MainActivity.cs
HtmlLabelRenderer.Initialize(); global::Xamarin.Forms.Forms.Init(this, bundle);
- UWP: App.xaml.cs
var rendererAssemblies = new[] { typeof(HtmlLabelRenderer).GetTypeInfo().Assembly }; Xamarin.Forms.Forms.Init(e, rendererAssemblies); HtmlLabelRenderer.Initialize();
How it works
On iOS and Android it uses the native HTML rendering capabilities of iOS's UILabel and Android's TextView.
UWP's TextBlock cannot renders HTML so the library parses the HTML and uses Inlines to display: <a>, <b>, <br>, <em>, <i>, <p>, <strong>, <u>, <ul> <li>, <div>
.
FontAttributes, FontFamily, FontSize, TextColor, HorizontalTextAlignment are converted into inline CSS in a wrapping <div>
for iOS and Android. UWP supports them natively.
Custom styling
If you need to customize something in Android or iOS you can use inline CSS, for example:
<span style="color: green">...</span>
For underlined text use the <u> tag:
<u>Some underlined text</u>
For links: remember to add the schema (http:// https:// // mailto:// ext...)
Supported Properties
- Text
- FontAttributes
- FontFamily
- FontSize
- TextColor
- HorizontalTextAlignment
Events
Navigating Navigated
Custom Properties
- MaxLines (int)
Usage XAML
xmlns:htmlLabel="clr-namespace:LabelHtml.Forms.Plugin.Abstractions;assembly=HtmlLabel.Forms.Plugin"
<htmlLabel:HtmlLabel Text="{Binding HtmlString}"/>
xmlns:htmlLabel="clr-namespace:LabelHtml.Forms.Plugin.Abstractions;assembly=HtmlLabel.Forms.Plugin"
<htmlLabel:HtmlLabel Text="{Binding HtmlString}" htmlLabel:HtmlLabel.MaxLines="2"/>
Usage C#
var label = new HtmlLabel();
label.Text = "..htmlstring.."
HtmlLabel.SetMaxLines(label, 3);
Limitations
- SetMaxLines and LineBreakMode.TailTruncation do not work properly;
- Using Links and custom fonts together could not work properly on iOS.
- Images won't be displayed on Android (TextView limitation).
Contributions
Contributions are welcome!
License
Under MIT, see LICENSE file.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 was computed. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid71 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. uap10.0.17134 is compatible. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.1)
- Xamarin.Forms (>= 3.0.0.550146)
-
.NETStandard 2.0
- Xamarin.Forms (>= 3.0.0.550146)
-
MonoAndroid 7.1
- Xamarin.Forms (>= 3.0.0.550146)
-
UAP 10.0.17134
- Microsoft.NETCore.UniversalWindowsPlatform (>= 6.1.5)
- Microsoft.Xaml.Behaviors.Uwp.Managed (>= 2.0.0)
- Xamarin.Forms (>= 3.0.0.550146)
-
Xamarin.iOS 1.0
- Xamarin.Forms (>= 3.0.0.550146)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Xam.Plugin.HtmlLabel:
Package | Downloads |
---|---|
Xamarin.Forms.InterfaceBuilder
InterfaceBuilder is an hepful api to write Xamarin.Forms user interfaces directly in sourcecode. It's heavly relying on the builder pattern. So you can write: var ui = new UI(); MainPage = ui.Page("MainPage", ui.Stack().With( ui.Label("A"), ui.Label("B"), ui.Label("C")) ); |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Xam.Plugin.HtmlLabel:
Repository | Stars |
---|---|
gruan01/XFControls
Xamarin.Forms Custom Control
|
Version | Downloads | Last updated |
---|---|---|
5.1.0 | 88,046 | 6/18/2022 |
5.0.2 | 954 | 6/18/2022 |
5.0.0 | 105,864 | 11/7/2020 |
5.0.0-alpha4 | 389 | 9/30/2020 |
5.0.0-alpha3 | 847 | 9/10/2020 |
5.0.0-alpha1 | 638 | 6/10/2020 |
4.1.3 | 133,709 | 6/23/2020 |
4.1.2 | 59,378 | 4/18/2020 |
4.1.1 | 2,984 | 4/5/2020 |
4.1.0 | 5,070 | 3/25/2020 |
4.0.1 | 4,361 | 3/15/2020 |
4.0.0 | 946 | 3/14/2020 |
4.0.0-preview.1 | 326 | 3/8/2020 |
3.0.2.2 | 113,133 | 3/18/2019 |
3.0.2.1 | 76,831 | 11/25/2018 |
3.0.1.6 | 23,671 | 8/26/2018 |
3.0.1.3-beta | 2,094 | 6/13/2018 |
2.2.0 | 24,088 | 3/24/2018 |
2.1.5 | 1,364 | 3/7/2018 |
2.1.4 | 2,514 | 2/5/2018 |
2.1.3 | 1,052 | 2/3/2018 |
2.1.2 | 1,485 | 1/29/2018 |
2.1.1 | 1,219 | 1/28/2018 |
2.1.0 | 1,508 | 1/15/2018 |
1.0.4 | 6,621 | 7/11/2017 |