Mercurial > dwindows
changeset 2538:1b3b40c89cd0
Android: Move the text to below the point, not above it.
Adjust the rect and origin based on the calculated text height.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 11 May 2021 22:53:29 +0000 |
parents | cd9d2ba251d5 |
children | 822f814a54f4 |
files | android/DWindows.kt |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/android/DWindows.kt Tue May 11 22:44:45 2021 +0000 +++ b/android/DWindows.kt Tue May 11 22:53:29 2021 +0000 @@ -1937,15 +1937,16 @@ paint.style = Paint.Style.FILL_AND_STROKE paint.textAlign = Paint.Align.LEFT paint.getTextBounds(text, 0, text.length, rect) - rect.top += y - rect.bottom += y + val textheight = rect.bottom - rect.top + rect.top += y + textheight + rect.bottom += y + textheight rect.left += x rect.right += x canvas.drawRect(rect, paint) // Restore the color and prepare to draw text paint.color = oldcolor paint.style = Paint.Style.STROKE - canvas.drawText(text, x.toFloat(), y.toFloat(), paint) + canvas.drawText(text, x.toFloat(), y.toFloat() + textheight.toFloat(), paint) } } }