0

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

Vikash Singh
  • 43
  • 1
  • 7

1 Answers1

0

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.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Okay, but what's the problem in exporting an individual view from figma as SVG rather than drawing an individual view in Canvas. – Vikash Singh Nov 05 '21 at 15:20
  • If all the view is doing is displaying an icon/image, that's what you would do. But how do you think ImageView works? It makes calls to Canvas. 99% of the time you won't be using Canvas directly, you'll be using Views that are already programmed to make those calls. But when you need to do something unique, you need to fall back to it – Gabe Sechan Nov 05 '21 at 15:23