Showing posts with label downloadablefonts. Show all posts
Showing posts with label downloadablefonts. Show all posts

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.

Steps

  • 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..................  ;)   

 

Copyright @ 2013 Android Developers Blog.