This is an Android widget, and I'm trying to add custom fonts to it.
This is my code:
public void updateAppWidget(Context context,AppWidgetManager appWidgetManager,int appWidgetId) { String currentTime = (String) df.format(new Date()); RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget1); updateViews.setImageViewBitmap(R.id.widget1label, buildUpdate(currentTime, context)); appWidgetManager.updateAppWidget(appWidgetId, updateViews); } public Bitmap buildUpdate(String time, Context context) { Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(context.getAssets(),"batmfo.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; }
Is there something wrong with the buildUpdate()
method? Eclipse does not show errors in Logcat.
user1092153
source share