android项目中的自定义字体(custom fonts in android project)
即时通讯尝试在我的项目中添加一个自定义字体,我看到了几个教程,并在所有这些教程中,他们添加了编程的fon,如下所示:
Typeface myTypeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/COOPPBL.TTF"); TextView tv = (TextView) view.findViewById(R.id.textview1); tv.setTypeface(myTypeface);Coukld有人告诉我是否有方法在XML中添加字体,而不是使用java,非常感谢。
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.
最满意答案
你不幸的是不能。 您只能以编程方式执行此操作,因为android不具有通过XML提供的内置支持。
You unfortunately cannot. You can do that programmatically only, as android does not have built-in support for that through XML.
更多推荐
发布评论