Reading the XML developer online developer page , I found the following statement:
Your user interface descriptions are external to your application code, which means that you can modify or adapt it without changing the source code or recompiling.
I know about the many benefits of XML layouts and resources, but since the XML files are located inside the APK, I think there is no real way to change the GUI without repackaging. I mean, most of us use the eclipse ADT and ANT plugins to package applications, so there is no real benefit in not compiling class files (since after changing the resource files, the developer will have to repack the application and create a new APK file). Because of this, it is not possible to relocate the GUI to devices without redeploying the entire APK.
If this assumption was true, then the XML files will be the same throughout the life cycle of the APK file. I suggest that these files (especially layouts) should be parsed and processed at runtime (before the onCreate action), which would be less efficient than creating a GUI programmatically (e.g. in Swing). The layout is usually not a bottleneck, but if I'm right, I see a small waste of time here that could be better used (for example, with animation).
Reading the same page, she states:
When compiling your application, each XML layout file is compiled into a View resource.
Checking one of my APKs, I was looking for a precompiled file inside classes.dex
and there was nothing but my java classes and R.class
file. The XML layout files are inside the /res/layout folder
, and there is a file called resources.arsc
which seems to contain information about other resources (strings, icon names) but nothing related to Views, I think (correct me, if I am wrong).
My questions:
- Are the XML files compiled and to which file?
- If not, is there a compilation option to completely precompile the layout information into a file for faster download times? (ideally this would be a class file)
- If not, is there a way to create this file in the first execution and cache it in the application installation folder so that subsequent executions at runtime can read this file instead of XML parsing and have faster download times?
Thanks in advance.
Mister smith
source share