Set custom font in tooltip, TextInputLayout

I am trying to set a custom font on Hint for TextInputLayout . Therefore, I use my own subclass of TextInputLayout with the custom property MyHint . This property installer should format the text and set FormattedText , but it does not work.

If I just set the FormattedHint property, it also does not format. Anyone why these approaches fail?

Below you can see my own class with a property.

Example:

 BaseTextInputLayout userNameInput = view.FindViewById<BaseTextInputLayout>(Resource.Id.myId); userNameInput.MyHint = "My Custom hint text"; 

Grade:

  public class BaseTextInputLayout: TextInputLayout { public string MyHint { get { return Hint; } set { if (value != null) { SpannableStringBuilder builder = new SpannableStringBuilder(value); builder.SetSpan(new CustomTypeFaceSpan("", Constants_Android.TYPEFACE_YOGA_MET_EVY_CUSTOMFONT), 0, builder.Length(), SpanTypes.InclusiveExclusive); this.HintFormatted = builder; } else { this.HintFormatted = null; } } } 
+5
source share
1 answer

I think you will need to use:

 userNameInput.Typeface = yourCustomTypeFace; 

I do not see much benefit to your subclass with this property, although you certainly can:

 public class BaseTextInputLayout: TextInputLayout { public string MyHint { get { return Hint; } set { if (value != null) { this.Typeface = yourCustomTypeFace; this.Hint = value; } else { this.Hint = null; } } } 
0
source

All Articles