2

I'm trying to learn how to draw a Google assistant chat bubble using Android Canvas with Path APIs, I have tried to draw a curved rectangle and it works, but I want to draw the bazier curve like Google assistant, I have tried cubicTo but it's not working with me.

private val radius = DEFAULT_RADIUS
private val boxRect = RectF(marginStart, marginEnd + marginEnd, maxWidth, height.toFloat())
private val boxCorners = floatArrayOf(0f, 0f, radius, radius, radius, radius, radius, radius)
boxPath.addRoundRect(boxRect, boxCorners, Path.Direction.CW)
boxPath.cubicTo(
    marginStart * 2,
    marginEnd * 2,
    marginStart * 2,
    marginEnd,
    marginStart * 2,
    0f
)
canvas?.drawPath(boxPath, boxPaint)

This image explains what I'm trying to do

enter image description here

camelccc
  • 2,847
  • 8
  • 26
  • 52
Mohamed Hamdan
  • 147
  • 2
  • 16

0 Answers0