简体   繁体   中英

Use of fontawesome in xamarin.forms (iOS and Android only)

In xamarin forms using icon as png file is very painfull with all the sizeand native stuff that you need to do and verify. I decide to use font awesome but this way i can't put in toolbar item and neither in some button tha need a text too. Do anyone has a guide to use as fileimagesource because the fontimagesource is not compatible to use in place of fileimagesource. Or, anyone has a guide to do presseffect with some code that i can use in all my stuff?

This is not possible

<ContentPage.ToolbarItems>
        <ToolbarItem>
            <ToolbarItem.Icon>
                <FontImageSource/>
            </ToolbarItem.Icon>
        </ToolbarItem>
    </ContentPage.ToolbarItems>

this is the way it works

<ContentPage.ToolbarItems>
        <ToolbarItem>
            <ToolbarItem.Icon>
                <FileImageSource/>
            </ToolbarItem.Icon>
        </ToolbarItem>
 </ContentPage.ToolbarItems>

Other way was to put in label and use with layouts but both of them dosen't have the press effect

I expect to use the press effect without plugin, using a easy render maybe, or at least i want to use fonticon in toolber item like a normal image or text.

Obs: Text of toolbar item dosen't have fontfamily, if there's a way to do this with converter I will be grateful.

Now with Xamarin 4.0 new release, this it's possible. The follow 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM