Adding custom Font to Theme in Android

前端 未结 6 1897
故里飘歌
故里飘歌 2020-11-29 19:35

Is there any way to add custom fonts in Themes in Android?

I have read Quick Tip: Customize Android Fonts, but here we have to programmetrically add custom font to

6条回答
  •  情话喂你
    2020-11-29 20:08

    I hope this is what you meant, but if it is not it should be a good reference for others anyway.

    ** Note: Fonts can be found Computer/Local Disk (C:)/Windows/Fonts **

    Copy the font that you would like to use in the Fonts folder above and paste it into a newly created folder in the assets folder in the Eclipse.

        private void initTypeFace()
        {
            TypeFace tf = TypeFace.createFromAsset(getAsset(),
                          "Chantelli Antiqua.ttf");
    
            TextView txt = (TextView) findViewById(R.id.custom_font);
    
            txt.setTypeface(tf);
            example_button1.setTypeface(tf);
            example_button2.setTypeface(tf);
        }
    

提交回复
热议问题