How to use custom fonts on Android

Asked 2 years ago, Updated 2 years ago, 143 views

I applied a custom font to TextView. But… I don't think my handwriting is changing properly. This is my code below.

Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
TextView myTextView = (TextView)findViewById(R.id.myTextView);
myTextView.setTypeface(myTypeface);

Please solve this problem.

android custom-font android-fonts android-typeface

2022-09-22 21:33

1 Answers

If you go to Mobiletuts, there is a good tutorial for converting text in an Android environment Quick Tip: Customize Android Fonts.

I just tested it myself and I'll tell you how. Create a subfolder named fonts inside the assets folder. Be careful not to make it a subfolder of the res folder. Then it's going to be like this, right?

assets/fonts

And the extension of the font file must be lowercase. It's not myFont.TTF, but myFont.ttf.


2022-09-22 21:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.