Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the font in Android widgets to user-defined fonts in "assets" folder of the app?

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?

like image 353
Majjoodi Avatar asked Aug 20 '10 21:08

Majjoodi


1 Answers

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/[email protected]/2009-06/msg00211.html

like image 139
shaemus mcgoo Avatar answered Nov 15 '22 06:11

shaemus mcgoo