0

I tried to add text to a drawable, but the only way I found was to make text into a bitmap and use layerdrawable. I tried the following code :

Bitmap canvasBitmap = Bitmap.createBitmap(sb.getWidth(), sb.getHeight(), Bitmap.Config.ARGB_8888);
Canvas imageCanvas = new Canvas(canvasBitmap);
imageCanvas.drawARGB(0, 0, 0, 0);
Paint p = new Paint();
p.setColor(Color.WHITE);
p.setTextSize(40);
imageCanvas.drawText("Sample text display here", 0, sb.getHeight()/2, p);
LayerDrawable background = new LayerDrawable(new Drawable[]{new BitmapDrawable(canvasBitmap)});

But the quality is poor compared to the other text fields.

I need a suggestion on how to either improve quality of the text or another way to add text to a drawable.

ipd
  • 5,674
  • 3
  • 34
  • 49
Mayank
  • 1,364
  • 1
  • 15
  • 29

0 Answers0