I would like to create a custom Floating action button with a round frame. like the following image
I ended up making a custom view for it. But it's so glitchy.
Here is the onDraw
function
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
val cx = (width / 2).toFloat()
val cy = (height / 2).toFloat()
val hShift = outerRadius * .4
val vShift = outerRadius * .05
circle.set(
(cx - outerRadius - hShift).toFloat(), (cy - 3 * outerRadius + vShift).toFloat(),
(cx + outerRadius- hShift).toFloat(), (cy - outerRadius+vShift).toFloat()
)
path.arcTo(circle, 0F, 85F)
path.lineTo(cx,cy-outerRadius)
circle.set(cx - outerRadius, cy - outerRadius, cx + outerRadius, cy + outerRadius)
path.arcTo(circle, 90F, 180F)
path.lineTo(cx,cy-outerRadius)
path.lineTo(cx, cy+outerRadius)
circle.set(
(cx - outerRadius- hShift).toFloat(), (cy + outerRadius - vShift).toFloat(),
(cx + outerRadius- hShift).toFloat(), (cy + 3 * outerRadius - vShift).toFloat()
)
path.arcTo(circle, 275F, 90F)
canvas.drawPath(path, paint)
}
My question: is this the right way to do it? I was thinking of a vector drawable as a background
PS: I also tried BottomNavigationView
but it's on the bottom by design