Monday, 27 November 2017

Android O: Fonts – Part 1 | Working with custom font Android O | Custom font | Fonts in XML

Hello Friends,
              Android 8.0 (API level 26) introduces a new feature, Fonts in XML, which lets you use fonts as resources. You can add the font file in the res/font/ folder to bundle fonts as resources. These fonts are compiled in your R file and are automatically available in Android Studio. You can access the font resources with the help of a new resource type, font. For example, to access a font resource, use @font/myfont, or R.font.myfont.

To use the Fonts in XML feature on devices running Android API version 14 and higher, use the Support Library 26. For more information on using the support library, refer to the Using the support library section.


  • To add fonts as resources, perform the following steps in the Android Studio

    • Right-click the res folder and go to New > Android resource directory       
    • The New Resource Directory window appears.

    • In the Resource type list, select font, and then click OK.

      Note: The name of the resource directory must be font.

  • Using fonts in XML layouts 
    • In the layout XML file, set the font Family attribute to the font file you want to access.

    Download Complete code from here.
    Hope this will help some one.
    Enjoy coding..................  ;)   

Mukesh Kumar

Hi Guys I am from Delhi working as Web/Mobile Application Developer(Android Developer), also have knowledge of Roboelctric and Mockito ,android test driven development... Blogging has been my passion and I think blogging is one of the powerful medium to share knowledge and ideas....


Post a Comment


Copyright @ 2013 Android Developers Blog.