如何改变字体在Android的小工具用户自定义的字体"资产"该应用程序的文件夹? [英] How to change the font in Android widgets to user-defined fonts in "assets" folder of the app?

查看:134
本文介绍了如何改变字体在Android的小工具用户自定义的字体"资产"该应用程序的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变字体在我的小工具,使得它使用一个特定的字体在我的应用程序的资产的文件夹。

I want to change the font in my widget such that it uses a specific font in "assets" folder of my app.

我通常在我的应用程序,以更改字体:

I usually do this in my app to change the font:

        Typeface tf= Typeface.createFromAsset(getAssets(), "advertising.ttf");
        TextView converted = (TextView)findViewById(R.id.TextView03);
        converted.setTypeFace(tf);

和它的工作原理就像一个魅力。

and it works like a charm.

我怎么能做到这一点的部件?我只能设置文本,改变颜色:

How can I do this in widgets? I can only set the text and change the color:

      remoteView.setTextViewText(R.id.TextView03,"some text" );
    remoteView.setTextColor(R.id.TextView03, Color.BLACK);

但我不明白的方式来设置字体。任何帮助吗?

but I don't see a way to set the font. Any help please?

推荐答案

遇到同样的问题,以及,发现这个: 因为小部件住在其他进程,他们只能用系统 字体,并且这可能是内部的不附加字体您 包。解决此问题的方法是使你的字体到 位图的过程,然后将其推跨RemoteViews。 发贴者杰夫·夏基在这里: <一href="http://www.mailinglistarchive.com/html/android-developers@googlegroups.com/2009-06/msg00211.html" rel="nofollow">http://www.mailinglistarchive.com/html/android-developers@googlegroups.com/2009-06/msg00211.html

Ran into the same problem as well and found this: "Because widgets live in other processes, they can only use system typefaces, and not additional fonts that might be internal to your package. One way around this would be to render your font onto a Bitmap in your process, and then push it across RemoteViews." Posted by Jeff Sharkey here: http://www.mailinglistarchive.com/html/android-developers@googlegroups.com/2009-06/msg00211.html

这篇关于如何改变字体在Android的小工具用户自定义的字体&QUOT;资产&QUOT;该应用程序的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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