<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Peedroca</title>
    <description>The latest articles on DEV Community by Peedroca (@peedroca).</description>
    <link>https://dev.to/peedroca</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F504979%2Ff770453d-bd78-4f3d-9510-7b43d099ab04.jpg</url>
      <title>DEV Community: Peedroca</title>
      <link>https://dev.to/peedroca</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/peedroca"/>
    <language>en</language>
    <item>
      <title>Material font icons on Xamarin Forms</title>
      <dc:creator>Peedroca</dc:creator>
      <pubDate>Wed, 04 Nov 2020 18:05:09 +0000</pubDate>
      <link>https://dev.to/peedroca/material-font-icons-on-xamarin-forms-2a9h</link>
      <guid>https://dev.to/peedroca/material-font-icons-on-xamarin-forms-2a9h</guid>
      <description>&lt;p&gt;Hello devs 🖖, recently I'm searching how to use Materialize icons in my mobile app maked with Xamarin.Forms 4.8, but I could't find a great step by step. Therefore I will try to do it today.&lt;/p&gt;

&lt;h3&gt;
  
  
  Font Source
&lt;/h3&gt;

&lt;p&gt;You need to download the TFF font at &lt;a href="https://github.com/google/material-design-icons" rel="noopener noreferrer"&gt;material design google repo&lt;/a&gt;, so go to material-design-icons &amp;gt; font &amp;gt; MaterialIcons-Regular.ttf.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using font icon
&lt;/h3&gt;

&lt;p&gt;Step 1. Put archieve &lt;code&gt;tff&lt;/code&gt; on folder &lt;code&gt;Fonts&lt;/code&gt; in your Xamarin Shared Project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F43295412%2F98149968-b08a6480-1eac-11eb-933a-59c652deea55.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F43295412%2F98149968-b08a6480-1eac-11eb-933a-59c652deea55.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't forget to set build action as Embedded resource.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Step 2. Add &lt;code&gt;ExportFont&lt;/code&gt; in your &lt;code&gt;App.xaml.cs&lt;/code&gt; as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;assembly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;ExportFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MaterialIconsRegular.ttf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Alias&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Material"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;MaterialApp&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;partial&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;InitializeComponent&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

            &lt;span class="n"&gt;MainPage&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;MainPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Alias&lt;/code&gt; is optional. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Step 3. Use a materialize font in any page you need.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;StackLayout&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Label&lt;/span&gt; &lt;span class="na"&gt;Text=&lt;/span&gt;&lt;span class="s"&gt;"&amp;amp;#xe87C;"&lt;/span&gt; &lt;span class="na"&gt;FontSize=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt; &lt;span class="na"&gt;TextColor=&lt;/span&gt;&lt;span class="s"&gt;"Orange"&lt;/span&gt;
           &lt;span class="na"&gt;FontFamily=&lt;/span&gt;&lt;span class="s"&gt;"Material"&lt;/span&gt; &lt;span class="na"&gt;HorizontalOptions=&lt;/span&gt;&lt;span class="s"&gt;"Center"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;      
&lt;span class="nt"&gt;&amp;lt;/StackLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You will need the hexadecimal code, You can get it at &lt;a href="https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.codepoints" rel="noopener noreferrer"&gt;MaterialIcons-Regular.codepoints&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I like to search icons on &lt;a href="https://material.io/resources/icons/?style=baseline" rel="noopener noreferrer"&gt;https://material.io/resources/icons/?style=baseline&lt;/a&gt; and get theirs names, so I find the hexadecimal code at MaterialIcons-Regular.codepoints. (you can find it in google repo.)&lt;/p&gt;

&lt;p&gt;That's all, folks.  😄&lt;/p&gt;

</description>
      <category>materialize</category>
      <category>icons</category>
      <category>xamarinforms</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
