0

It is a well-known fact that inflating from XML requires accessing the disc, so it should be normally slower than inflating the UI layouts from Java code via creating View instances.

I was trying to find any ready solutions for generating Java layouts from XML but didn't find any. So I made my own measurements and to my big surprise I discovered that on fast devices (S6 and Nexus5 with Android 6.0) complex RelativeLayouts with nested elements are getting inflated even faster from XML, than from Java code!

Do you have any idea why this is happening?

mike
  • 1
  • 2
  • no, they cannot be created faster using the xml, but the overall difference should not be any big though, so use xml as it is way much easier and pretty fast as well – pskink Jul 28 '16 at 15:42
  • my results show that layouts are created 15% faster using xml, but only for complex layouts and only on fast devices. So maybe anyone knows the reason. – mike Jul 28 '16 at 15:49
  • so there is a problem with your java code why it is that slow: after all inflating from xml first reads resources, 2) parses the xml 3) uses even slower `View` constructors as it has to use the reflection which is not a speed daemon – pskink Jul 28 '16 at 15:53

0 Answers0