Change TextView Font?

前端 未结 3 1673
悲哀的现实
悲哀的现实 2020-12-21 17:11

How can I change font type in Android TextView?



        
3条回答
  •  眼角桃花
    2020-12-21 17:32

    You can programatically set the desire font by placing your font file (example.tff) style in Assets/fonts and then give your own string into fontpath variable

        String fontPath="fonts/Unkempt-Regular.ttf";
        TextView aboutus=(TextView)findViewById(R.id.aboutus);
        Typeface type=Typeface.createFromAsset(getAssets(), fontPath);
        aboutus.setTypeface(type);
    

提交回复
热议问题