Skip to content

Commit

Permalink
Fix mention span height when rendered next to big image or similar
Browse files Browse the repository at this point in the history
Change-Id: I47b775a1d81a1e5f6417943d574990904c937787
  • Loading branch information
SpiritCroc committed Dec 27, 2024
1 parent 59d7cc8 commit 2bf8b54
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ class MentionSpan(

override fun draw(canvas: Canvas, text: CharSequence?, start: Int, end: Int, x: Float, top: Int, y: Int, bottom: Int, paint: Paint) {
// Extra vertical space to add below the baseline (y). This helps us center the span vertically
val extraVerticalSpace = y + paint.ascent() + paint.descent() - top
//val extraVerticalSpace = y + paint.ascent() + paint.descent() - top

val rect = RectF(x, top.toFloat(), x + textWidth + startPadding + endPadding, y.toFloat() + extraVerticalSpace)
//val rect = RectF(x, top.toFloat(), x + textWidth + startPadding + endPadding, y.toFloat() + extraVerticalSpace)
val rect = RectF(x, y.toFloat() + paint.ascent(), x + textWidth + startPadding + endPadding, y.toFloat() + paint.descent())
val radius = rect.height() / 2
canvas.drawRoundRect(rect, radius, radius, backgroundPaint)
paint.color = textColor
Expand Down

0 comments on commit 2bf8b54

Please sign in to comment.