title: How to create rounded corners in background of multiline text, where lines have different width
body: <p>I need to make background color of text in EditText like in the picture.</p>
  <p>Making corners rounded and paddings is quite easy with custom <code>LineBackgroundSpan</code>. I implemented it like this:</p>
  <pre><code>class RoundedCornersBackgroundSpan(val padding: Int,
                                 val backgroundColor: Int) : LineBackgroundSpan {
  
  val backgroundRect = Rect()
  
  override fun drawBackground(c: Canvas, p: Paint, left: Int, right: Int, top: Int, baseline: Int, bottom: Int, text: CharSequence?, start: Int, end: Int, lnum: Int) {
      if(text == null) return
      val textWidth = Math.round(p.measureText(text, start, end))
      val paintColor = p.color
      backgroundRect.set(left - padding,
              top - if(lnum == 0) { padding / 2 } else { - (padding / 2 ) },
              left + textWidth + padding,
              bottom + (padding / 2))
      p.color = backgroundColor
      c.drawRoundRect(RectF(backgroundRect), 3.fromDpToPixelsF(), 3.fromDpToPixelsF(), p)
      p.color = paintColor
  }}
  </code></pre>
  <p>But how can I implement this &quot;inner&quot; corners, which annotated with arrows in the picture?
  <a href="https://i.stack.imgur.com/rW2IQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rW2IQ.png" alt="picture with desired effect" /></a></p>