다음과 같은 방법을 사용할 수 있습니다.
글꼴을 캔버스에 렌더링 한 다음 비트 맵에 전달하고 ImageView에 할당합니다.
public Bitmap buildUpdate(String text)
{
Bitmap myBitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_4444);
Canvas myCanvas = new Canvas(myBitmap);
Paint paint = new Paint();
Typeface mytypeface = Typeface.createFromAsset(this.getAssets(),"fontname.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(text, 80, 60, paint);
return myBitmap;
}
가 좋아 사용
String text = "This is my text";
RemoteViews views = new RemoteViews(getPackageName(), R.layout.my_widget_layout);
views.setImageViewBitmap(R.id.my+imageview, buildUpdate(text));
희망이 :)
도움이 될 것입니다