android项目中的自定义字体(custom fonts in android project)

编程入门 行业动态 更新时间:2024-10-27 12:39:15
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.

更多推荐

本文发布于:2023-07-28 23:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1310182.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   字体   项目   android   fonts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!