Custom fonts and XML layouts (Android)

后端 未结 18 1880
执念已碎
执念已碎 2020-11-22 07:21

I\'m trying to define a GUI layout using XML files in Android. As far as I can find out, there is no way to specify that your widgets should use a custom font (e.g. one you\

18条回答
  •  礼貌的吻别
    2020-11-22 07:40

    The best way to do it From Android O preview release is this way
    1.)Right-click the res folder and go to New > Android resource directory. The New
    Resource Directory window appears.
    2.)In the Resource type list, select font, and then click OK.
    3.)Add your font files in the font folder.The folder structure below generates R.font.dancing_script, R.font.la_la, and R.font.ba_ba.
    4.)Double-click a font file to preview the file's fonts in the editor.

    Next we must create a font family

    1.)Right-click the font folder and go to New > Font resource file. The New Resource File window appears.
    2.)Enter the file name, and then click OK. The new font resource XML opens in the editor.
    3.)Enclose each font file, style, and weight attribute in the font tag element. The following XML illustrates adding font-related attributes in the font resource XML:

    
    
        
        
    
    

    Adding fonts to a TextView:

       
    

    As from the documentation

    Working With Fonts

    all the steps are correct.

提交回复
热议问题