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?
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
for widget such a few presets for fonts, but only - normal, sans, serif, monospace. My example
<TextView android:id="@+id/UniStringLineHeadTxtTime1" android:text="" android:layout_width="wrap_content" android:layout_height="14dp" android:textStyle="bold" android:typeface="normal" android:textSize="9dp" android:textColor="#F0F0F0" android:paddingLeft="2dp" android:paddingTop="1dp" />
精彩评论