2

I'm using a view and drawing over a bitmap some text,it does not have a fixed size, so I want the text to fit the rectangle I define and if it's needed split the string in some lines. I don't know how to do it in android. I found one solution using StaticLayout, but doesn't work. Here is my code:

Bitmap arBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ar_bitmap);
canvas.drawBitmap(arBitmap ,bitmapPos,20,  null);ll);
Paint paint = new Paint(); 
paint.setStyle(Paint.Style.FILL); 
paint.setColor(Color.WHITE);
canvas.drawText(textToDisplay,textPos , 35, paint);

Thanks

dakshbhatt21
  • 3,318
  • 3
  • 27
  • 37
Alex
  • 31
  • 2
  • 4

1 Answers1

1

I wrote a blog post on this and made code available on github. http://catchthecows.com/?p=72

In addition, do check out other solutions from folks in the answer to the question that @Nathan Fig refers to.

slund
  • 6,027
  • 2
  • 24
  • 18