如何为Android小部件设置自定义字体? [英] How to set custom typeface for an android widget?

查看:116
本文介绍了如何为Android小部件设置自定义字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发一个显示一些句子的Android小部件,

问题是我无法将字体传递给小部件。

当我使用mytextview.settypeface(...);该计划以强制关闭。

任何帮助将不胜感激,

tnx提前

Hi I am developing an android widget which displays some sentences,
the problem is that I cannot pass typeface to the widget.
and when I use mytextview.settypeface(...); the program comes out with force close.
any help would be appreciated,
tnx in advance

推荐答案

如果没有看到你的代码并且不知道抛出什么异常,那么接下来就是猜测。我认为你使用的是以下内容?



Without seeing your code and without knowing what exception is being thrown what follows is all guesswork. I take it you are using something like the following?

String fontFamily = "Arial";
Typeface tf = Typeface.Create(fontFamily, Typeface.DEFAULT);
myTextView.setTypeface(tf);





  • 您对myTextView有空引用吗?
  • 如果字体系列不可用,Typeface.Create()会返回什么?

  • 这篇关于如何为Android小部件设置自定义字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆