如何将 Android 小部件中的字体更改为“资产"中的用户定义字体应用程序的文件夹? [英] How to change the font in Android widgets to user-defined fonts in "assets" folder of the app?

查看:21
本文介绍了如何将 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);

它就像一个魅力.

如何在小部件中执行此操作?我只能设置文字和改变颜色:

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 中."杰夫·夏基在这里发表: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 小部件中的字体更改为“资产"中的用户定义字体应用程序的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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