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?