简体   繁体   中英

custom fonts in android project

im trying to add a custom font in my project, I saw severals tutorials, and in all of them they add the fon programaticly like the following:

Typeface myTypeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/COOPPBL.TTF");
    TextView tv = (TextView) view.findViewById(R.id.textview1);
    tv.setTypeface(myTypeface);

Coukld someone tell me if there a way to add the font in the XML and not using java, thanks a lot.

You unfortunately cannot. You can do that programmatically only, as android does not have built-in support for that through XML.

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