Wrapping long text on an Android Canvas

后端 未结 3 1692
半阙折子戏
半阙折子戏 2020-12-15 18:30

I have a custom control that is doing a lot of 2D drawing straight to the canvas.

Some of this drawing is text, so I am using the Canvas.drawText() meth

3条回答
  •  北海茫月
    2020-12-15 19:12

    You can use the android.text.StaticLayout class for this; simply create a StaticLayout for the desired text, alignment, width, etc. and call its draw(Canvas) method to draw to the canvas.

提交回复
热议问题