0
我可以設置字體與Java腳本的字體,但它是一種方式來設置自定義字體,而無需編程的部件屬性面板或設計文本模式或其他?如何在Widget屬性面板中設置字體字體?
我可以設置字體與Java腳本的字體,但它是一種方式來設置自定義字體,而無需編程的部件屬性面板或設計文本模式或其他?如何在Widget屬性面板中設置字體字體?
您的問題已在這裏How to use a custom typeface in a widget?
回答這是一個例子。
public Bitmap buildUpdate(String time)
{
Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444);
Canvas myCanvas = new Canvas(myBitmap);
Paint paint = new Paint();
Typeface clock = Typeface.createFromAsset(this.getAssets(),"Clockopia.ttf");
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(clock);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(65);
paint.setTextAlign(Align.CENTER);
myCanvas.drawText(time, 80, 60, paint);
return myBitmap;
}
這是做字體形象的事的一部分,這是如何使用它:
String time = (String) DateFormat.format(mTimeFormat, mCalendar);
RemoteViews views = new RemoteViews(getPackageName(), R.layout.main);
views.setImageViewBitmap(R.id.TimeView, buildUpdate(time));
你可以把它調整到您的需要
只能支持者之間進行切換在'android:typeface'屬性中。 – CommonsWare