Is parsing XML files in android at runtime or compile time?

I am far from expert when it comes to understanding the code compilation tune. But I'm learning some Android developments, and I noticed how layouts and other things are essentially xml-aware. I was wondering if this parsing happens at compile time or at runtime? If this is at run time, it seems that there may be some overhead associated with parsing a very complex layout.

I hope this question is not too vague or does not make sense.

+4
source share
2 answers

XML parsing for layout is done at compile time. You will notice that if something in your XML is malformed, the compiler will throw an error.

Some aspects of the layout, such as calculating the relative position, occur at run time, but there is nothing to be done to avoid this.

+2
source

Parsing occurs both at runtime and at compile time for different purposes. First, compilation typically uses layouts and drawings, which are analyzed for rendering by the layout editor and to add identification links for the code. Styles, themes, and attributes are also collected at this point, which allows you to use a very powerful set of XML resources.

Analysis of runtime occurs for each resource, "on the fly" and as necessary. This is achieved using several classes of inflatable elements and other supporting classes.

0
source

All Articles