Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

android paint drawtext multiline

// Kotlin language
val fm = paint.fontMetrics
val lineHeight = fm.bottom - fm.top + fm.leading
mText.split("
").forEachIndexed { idx, line ->
    val baseline = idx * lineHeight + (-fm.top)  // fm.top is negative
    canvas.drawText(line, 0f, baseline, paint)
}
 
PREVIOUS NEXT
Tagged: #android #paint #drawtext #multiline
ADD COMMENT
Topic
Name
9+6 =