But the Two line, If I set both of LineNumber and MaxLineNumber, it does not work. Text will makes third line.
You can create a custom label control and consume it in your Xaml:
CustomLabel:
public class CustomLabel:Label
{
}
Xaml:
<ContentPage ...
xmlns:local="clr-namespace:LabelDemo"
...>
<local:CustomLabel Text="I'm a baby not robot. \nPlease give me a milk" VerticalOptions="Center" HorizontalOptions="Center" />
Then create a custom renderer in your Droid project like below:
using Android.Widget;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
[assembly:ExportRenderer(typeof(LabelDemo.CustomLabel),typeof(LabelDemo.Droid.MyLabelRenderer))]
namespace LabelDemo.Droid
{
public class MyLabelRenderer:LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (Control != null)
{
var text = Control.Text;
text = text.Replace("\\n", "\n");//"\n" in shared project will be automatically transformed into "\\n", so we need to change it back
Control.SetLines(2);
Control.SetText(text, TextView.BufferType.Normal);
}
}
}
}