We love everything that makes the process of building beautiful applications easier. Using font Icons in Xamarin Forms apps makes this easier. Having to skip the process of creating and adding manually every icon for our application is just awesome. Font Icons are a great tool which we can leverage for this purpose.

Several months ago, I wrote this blog post about adding Font Awesome Icons in your Xamarin Forms applications. Now, here is a simple blog post about using Bootstrap and Material font icons in your Xamarin Forms apps.

If you like this post, you can chose to follow me on Twitter or Github and subscribe to this page’s notifications to stay updated with new articles or like my page on Facebook.

Getting The Font Icons

These steps explains how to get the font icons. For Bootstrap and Material Design.

Here is the source code for this demo app.

Bootstrap

You can get bootstrap glyph icons from github. Here is the link to the file. Make sure you get the file named: “glyphicons-halflings-regular.ttf”. This file will be added later to our platform projects.

Material Design

Material design font icons can be downloaded from this source: here is the link. Click the big download button at the top right corner of the page.

Adding Font Icons in Xamarin Forms

The font icons should be added in the platform specific projects. There is a specific way to add font icons for each platform.

Android

On Android, it is easy to add the font icons to your app. Just add the font icons to your Assets folder in your android platform specific project.

iOS

On iOS, you need to add the font icons to the Resources folder in the iOS project. Then, edit the info.plist file.

Adding Font Icons in Xamarin Forms Projects (iOS, Android)
Adding Font Icons in Xamarin Forms Projects (iOS, Android)

Accessing The Fonts in Your App

To display these fonts in your app, you can add it as a resource and call the resource as font style for a Label.

Bootstrap

After defining the Bootstrap resource, we use it as font style for any label which should contain bootstrap icons.

Material Design

Above we defined a Material Design font style resource. This will be designed a the Font style of every label which serves as icon in your app.

Using the Font Icons in your App

To display the icons in your app, you need to get the code for each icon. Either Bootstrap or Material design.

Bootstrap

To get bootstrap icons code, you can follow this link. Select the icon you want to add and get its “Unicode HTML Entity”. This code will be added to your XAML preceding the “&#x” characters and ending with “;” character. As follows:

Material Design

To get Material design icon codes, you can navigate to this tool . Browse and upload your font icons file. It will generate the code for each font as used in C#. To use the code generated in XAML, replace the ‘\u’ character with ‘&#x’ and at the end add a ‘;’.

Here is the source code for this demo app.

Conclusion

Leveraging font icons can help us go faster in the process of app development. Hopefully, this post will permit you to leverage these tools easily. You can find a little more about Material Design icons in Xamarin.Forms via this blog post by James Montemagno.

If this post was useful to you, follow me on Twitter,  Github, Linkedinor like my Facebook page to stay updated.Follow me on social media and stay updated


Want to get your idea turned into software ? Visit To Tech.Follow me on social media and stay updated

Follow me on social media and stay updated
%d bloggers like this: