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
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…
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
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…
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…
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?
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…
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…
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 =…
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…
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…
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…
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…
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…
1
2 3 4 5 6