androidcanvasadobe-xdfigma

Why to use Canvas in Android?


I am new to Android Canvas

And i am just wondering why to use Canvas in Android, if I can export Design files from Figma or Adobe XD and directly use it in my Android App


Solution

  • You're comparing two completely different concepts. Your layout from Figma is equivalent to your content view- a set of views that make up a screen. Canvas is used to draw a single view. So if you were creating a TextView from scratch, you'd use the Canvas in onDraw to tell it where to draw the text, how big to draw it, etc (and if you look up how TextView is actually implemented, that's how it works). If you were making a custom view that lets you draw lines on top of an image to mark it up, you'd use canvas to draw the lines and the image. Canvas is about drawing an individual view. It's not about making a complex layout.