Maximum number of LinearLayout that can be nested in one XML file?
2 answers
Tree depth mapping is, in practice, limited by the size of the UI element stack, which is required to recursively traverse the view tree in measure / draw operations. The stack size depends on the API level and is 8kB, 12kB, or 16kB. There is no specific number as a depth limit; in practice you will see StackOverflowError
in low complexity devices after a few dozen or so nested views.
Lint will nag if you have nesting level 10 or deeper in the same layout file. It does not parse the depth of the run-time layout hierarchy.
Think about how to keep your view hierarchy as flat as possible.
+7
source to share