简体   繁体   中英

How to install external fonts into android studio for low target versions?

I was looking for some client approved fonts for my android application. but the problem is how can i make my android application supportable for external fonts. Because in the assets/fonts folder the files seem to be invalid with ? sign in them.

Thank you.

put your file TTF files in Assets/fonts .then

TextView myTextView=(TextView)findViewById(R.id.textBox);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/mytruetypefont.ttf");
myTextView.setTypeface(typeFace);

here is very good tutorial on this click here

If you're using Android Studio, you can use this library: Calligraphy

So you can still use your fonts from the assets/fonts folder, then use the dependency for injecting the font in the layouts you want to use your custom font.

See the read me for more info and sample for implementing it.

For the font extension, I think Android supports .ttf fonts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM