0

I have applied button attributes as shown below in xamarin forms. It works fine on iOS but creating problem on android.

    Button anyButton = new Button ();
    anyButton.Text = "Men";
    anyButton.FontFamily = "HelveticaNeue-Light" ;
    anyButton.FontSize = 16;
    anyButton.TextColor = Color.Black;
    anyButton.FontAttributes = FontAttributes.None;

Screen shots of the same view having same attributes are attached. Button text looks bold a bit in android as compared to iOS. I have tried by creating button renderer for Android and given attributes as

    Typeface fontStyle = Typeface.Create("HelveticaNeue-Light", TypefaceStyle.Normal);
    Control.SetTextColor(Android.Graphics.Color.ParseColor(Colors.BLACK_COLOR));
    Control.SetTextSize(Android.Util.ComplexUnitType.Sp, 16);
    Control.Typeface = fontStyle;

But still facing the issue cannot apply "light" font on button's text in android.

Android

iOS

1 Answers1

0

Android does not have a "helvetica" font. Their alternative is Roboto, (Helvetica Alternative in Android)

You could try doing a

Device.OnPlatform(...)

call to make this work (https://developer.xamarin.com/api/member/Xamarin.Forms.Device.OnPlatform/) They even have an example on the API doc utilizing fonts.

Either this option, or you will need to try using a custom renderer and downloading a font similar to helvetica.

Patrick Zawadzki
  • 456
  • 2
  • 6
  • 26