android paint drawtext multiline

Solutions on MaxInterview for android paint drawtext multiline by the best coders in the world

showing results for - "android paint drawtext multiline"
Gianluca
09 Oct 2019
1// Kotlin language
2val fm = paint.fontMetrics
3val lineHeight = fm.bottom - fm.top + fm.leading
4mText.split("\n").forEachIndexed { idx, line ->
5    val baseline = idx * lineHeight + (-fm.top)  // fm.top is negative
6    canvas.drawText(line, 0f, baseline, paint)
7}