2017-02-19 152 views

回答

0

您的问题已在这里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)); 

你可以把它调整到您的需要