Xamarin Forms Icons

I am wondering how I can implement icons in my Xamarin Forms application. I want to use something like glyphs or fonts. However, I have no idea how to embed it in my xaml / C # pages.

Ideally, I aim for something like this:

enter image description here

If someone could provide code to display an icon, such as a search bar or three lines, that would be great. I can format it to look beautiful. I'm struggling with how to actually pull out the icon!

+9
source share
3 answers

The easiest way is to use https://github.com/jsmarcus/Xamarin.Plugins.

Visual Studio Xamarin Studio :

  • Xam.Plugin.Iconize
  • Xam.Plugin.Iconize.FontAwesome
  • Xam.FormsPlugin.Iconize

: Xam.Plugin.Iconize.Material , .

Android MainActivity, OnCreate()

FormsPlugin.Iconize.Droid.IconControls.Init(Resource.Id.toolbar);
Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule());

iOS AppDelegate, FinishedLaunching()

FormsPlugin.Iconize.iOS.IconControls.Init();
Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule())

, iOS info.plist

<key>UIAppFonts</key>
<array>     
    <string>iconize-fontawesome.ttf</string>
</array>    

XAML, ,

<ContentPage ...
xmlns:iconize="clr-namespace:FormsPlugin.Iconize;assembly=FormsPlugin.Iconize" ...
>

<ContentPage.ToolbarItems>
    <iconize:IconToolbarItem Order="Primary" Clicked="..." Icon="fa-search" IconColor="White" />
</ContentPage.ToolbarItems>
+5

, Fontawesome Xamarin.Forms Android, . .

ios . .

0

Xamarin Forms, ! fooobar.com/questions/17128848/...

But it is so. The following code works just fine:

<Button  Text="Pesquisar">
    <Button.ImageSource>
         <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
    </Button.ImageSource>
</Button>

And this too:

<ContentPage.ToolbarItems>
    <ToolbarItem>
        <ToolbarItem.IconImageSource>
             <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
        </ToolbarItem.IconImageSource>
    </ToolbarItem>
</ContentPage.ToolbarItems>
0
source

Source: https://habr.com/ru/post/1678885/


All Articles