Articles in this section

How to set custom font for items loaded in xamarin.forms listview?

In ListView, you can use custom font for the elements instead default fonts for the ItemTemplate loaded with label, button, and more.

To use the custom fonts, place the custom font files in True Type Font (TTF) format in Xamarin projects.

Android

Place the ttf file in Assets folder and ensure the build type is set to AndroidAsset.

 

UWP

Place the ttf font file in Assets folder and ensure the build action is set to Content.

iOS

Place the ttf file in Resources folder and ensure the build type is set to BundleResource.

 

In addition, add the file names of the fonts that you want to use in info.plist.

<plist>
<key>UIAppFonts</key>
<array>
    <string>Pacifico-Regular.ttf</string>
</array>
</dict>
</plist>

 

Xaml

 
<ContentPage xmlns:syncfusion="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms" >
     <ContentPage.Resources>
        <ResourceDictionary>
            <OnPlatform x:TypeArguments="x:String" x:Key="Pacifico-Font">
                <On Platform="Android" Value="Pacifico-Regular.ttf#Pacifico" />
                <On Platform="UWP" Value="/Assets/Pacifico-Regular.ttf#Pacifico" />
                <On Platform="iOS" Value="Pacifico-Regular" />
            </OnPlatform>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.Content>
        <Grid>
          <Image Source="{Binding BackgroundImage}" Aspect="AspectFill"/>
         <syncfusion:SfListView x:Name="listView" ItemsSource="{Binding contactsinfo}">
               <syncfusion:SfListView.GroupHeaderTemplate>
                      <DataTemplate>
                           <ViewCell>
                 <Label Text="{Binding Key}" FontFamily="{StaticResource Pacifico-Font}" />                          
                           </ViewCell>
                     </DataTemplate>
                </syncfusion:SfListView.GroupHeaderTemplate>
           </syncfusion:SfListView>
        </Grid>
    </ContentPage.Content>
</ContentPage>
 

 

Sample Link : CustomFontSample

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied