Questions tagged [android-jetpack-compose-canvas]
79 questions
20
votes
2 answers
How do I make a dotted/dashed line in Jetpack Compose?
I'd need to replicate android XML view from this answer but in Jetpack Compose with pure kotlin

Phil Dukhov
- 67,741
- 15
- 184
- 220
17
votes
2 answers
How to outline text in Jetpack Compose
I have a Jetpack Compose Text() element that I'd like to outline in black like so .
Anyone know how to do this?
I've tried using the border() modifier, but that just adds a border around the rectangular area containing the text. I've also tried…

ichen2
- 396
- 1
- 5
- 13
6
votes
1 answer
How to make Rainbow border animation for box in compose?
How to make Rainbow border animation for box in compose, all the examples that I saw are for Circle and they use rotate with drawbehind, but what I really need is to make the same for a Box in compose.
Thanks
With rotate but it didn´t work

Talal
- 61
- 4
6
votes
1 answer
How to draw on Jetpack Compose Canvas using touch events?
This is Q&A-style question since i was looking for a drawing sample with Jetpack Canvas but questions on stackoverflow, this one or another one, i found use pointerInteropFilter for drawing like View's onTouchEvent MotionEvents which is not advised…

Thracian
- 43,021
- 16
- 133
- 222
6
votes
2 answers
Animating circle drawing in Jetpack compose
I am trying to animate circle drawing using drawCircle on Canvas as follows:
drawCircle(
color = Color.Black,
radius = 200f * animatableCircle.value,
center = Offset(size.width / 4, size.height / 4),
style = Stroke(2f)
)
It…

Varsha Kulkarni
- 1,389
- 2
- 13
- 17
5
votes
2 answers
Draw legend of pie chart (donut chart) in center of segment
I need to implement a donut chart with a legend for each sector in the center of the slice. I use compose and there are no problems with the chart itself, but I don't understand how to draw text in the middle of each sector
The picture shows an…

tasjapr
- 632
- 4
- 13
5
votes
2 answers
Jetpack Compose: How to draw a path / line like this
I want to achieve something like the below picture using canvas.
How can I achieve something like this?
Is there some reference that I can look up?

Webster
- 1,113
- 2
- 19
- 39
5
votes
1 answer
how to draw a square with stroke and neon glow with Jetpack Compose Canvas?
I need to draw a rounded square, something like drawRoundRect, but only the outline.
something like this.
this image is drawn by hand, as I said I need it to look like drawRoundRect but without outline (I don't want it to look hand drawn)
If you…

chrrissoft
- 149
- 1
- 10
4
votes
1 answer
How to center Text in Canvas in Jetpack compose?
I am creating a custom composable in Jetpack Compose using Canvas.
How to center text when using drawText?
Code
@OptIn(ExperimentalTextApi::class)
@Composable
fun MyCenterTextInCanvas() {
val width: Dp = 200.dp
val height: Dp = 40.dp
val…

Abhimanyu
- 11,351
- 7
- 51
- 121
4
votes
2 answers
Cutting one shape from an other shape in Jetpack Compose
I had a question about making this view in Compose and I have no idea about implementing it.
My current code looks like this:
Box(
modifier = Modifier
.fillMaxSize()
.height(300.dp)
) {
Canvas(modifier =…

Ghasem
- 467
- 5
- 8
4
votes
3 answers
Recomposition of Canvas in Jetpack Compose
I'm using Jetpack Compose to implement my requirement of drawing a 'Gradual growing line', i.e a line that starts from a specified start and point and gradually 'grows' until it reaches a specified end point.
I had earlier implemented this with…

Sparsh Dutta
- 2,450
- 4
- 27
- 54
3
votes
2 answers
draw round corners in canvas with drawArc
I'm trying to create a pie chart in Jetpack Compose. I'm trying to make corners round for each Pie in the Chart. But, I'm having issues making corner rounds. I tried using cap = StrokeCap.Round in drawArc in canvas, but did not get any luck making…

Abp
- 113
- 5
- 26
3
votes
1 answer
Jetpack compose Canvas Arch extra Stroke
I'm using a canvas in jetpack compose to draw a circle formed by multiple arches. And to for the arches to look better I set the cap to a round shape.
style = Stroke(width = chartBarWidth.toPx(),
cap = StrokeCap.Round)
The…

avram andrei tiberiu
- 65
- 3
3
votes
1 answer
Drawing text in Jetpack Compose with precision
I was trying to draw text inside circle and square in Jetpack Compose and I encounter this issue.
The text holder/container (I am not sure what we call it), the light red rectangle, which holds the actual text, doesn't center the text drawn.
I…

skafle
- 627
- 1
- 6
- 16
3
votes
1 answer
How to check which arc or pie chart segment clicked in Jetpack Compose?
This is a share your knowledge, Q&A-style question inspired by this question to detect which section of arc segment or degree of touch inside a circle or semi-circle as in gif and image below. Also how stroke width changes are set by default inwards…

Thracian
- 43,021
- 16
- 133
- 222