I want to draw text on a canvas like the below pic...
# compose
r
I want to draw text on a canvas like the below picture. variable2 can be null but the text should always be in the center. How can I measure or draw this kind of multiline text perfectly in the center?
c
Is there a reason for doing this with the canvas API?
r
I have other things to draw in this canvas. Using box column etc. would be complex so I though about raw canvas.
c
Could you share the other things? And AFTER sharing the other things could you share the whole problem?
👍 1
c
I am pretty sure that you should use
Box
etc, it is not as complex as manually drawing things to canvas. 🙂
c
I also though about it and then I read it again, he mentioned he is "drawing" more things
depending on what you are drawing I would agree but you can always do something like an enum or a sealed class to be able to detect what kind of content you are going to present and then decide on the presentation strategy. Having said that, I would avoid using canvas just because you are already using this. I can imagine a very specific scenario I would avoid trying multiple ways to present something but I feel like you can just use Box when you are presenting this content and when you are going to present your drawing content you could use the canvas.\
r
Something like this but with line break before and after + symbol
c
You do not need Canvas for this at all. Use the usual compose UI API.
❤️ 1
c
There is a very cool post somewhere on how to make shapes.
r
Ok Thanks, guys. Actually, I wanted to make some templates like this. Since they made it with vector graphics tools, I thought it might get complex at a certain point so that I would have to draw a path or maybe complex positioning. That's why I chose canvas. Anyway, I will try my best with compose API to see if I can do what I want. Thanks again.
👍🏽 1
👍 1