I am trying to draw multiline text with StaticLayout but the setMaxLines()
does not seem to work. This is my code:
val eventText = StaticLayout.Builder
.obtain(event.title, 0, event.title.length, eventTextPaint, (contentWidth / 7f).toInt())
.setMaxLines(2)
.build()
withTranslation(event.left, event.top * scale) {
eventText.draw(this)
}
But the all of the text is drawn which is 5 lines long. If I add setEllipsize(TextUtils.TruncateAt.END)
I get two lines which is specified in code but with "..." at end, which I do not want. What am I doing wrong? Or is the Builder broken?