Skip to content Skip to sidebar Skip to footer

Xml-driven Guis And Performance

Reading the Online Developer Guide page on XML layouts, I've found the following statement: Your UI descriptions are external to your application code, which means that you can mo

Solution 1:

If you have a gander at the class documentation for LayoutInflater, you'll notice they say:

For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; it only works with an XmlPullParser returned from a compiled resource (R.something file.)

So yes, layout files are indeed precompiled to some degree, and, judging by the above excerpt, it would be in the R$layout.class output file (but I'm not 100% sure on that). The precompiled layout file is located in your compiled APK package, as /res/layout/<layout_id>.xml. You'll notice if you extract it and open it in a text editor that most plain-text XML elements have been mapped to some binary form.

It would probably be the same kind of compression you can see in AndroidManifest.xml files that get packaged into the APKs.

Post a Comment for "Xml-driven Guis And Performance"