Skip to content Skip to sidebar Skip to footer

How Many Viewgroup (linearlayout, Relative, Grid, Etc..) Considered Too Many?

I tried to find an answer for this specific question but I couldn't. I watched a video https://www.youtube.com/watch?v=NYtB6mlu7vA and I got the impression that over using Layouts

Solution 1:

According to Lint Checks:

Layout has too many views

The maximum view count defaults to 80 but can be configured with the environment variable ANDROID_LINT_MAX_VIEW_COUNT.

Layout hierarchy is too deep

Layouts with too much nesting is bad for performance. Consider using a flatter layout (such as RelativeLayout or GridLayout).The default maximum depth is 10 but can be configured with the environment variable ANDROID_LINT_MAX_DEPTH.

According to my experience:

If your app supports api 9+ I recommend having less than 12 nested views. Usually these devices have limitations on memory. You can get OutOfMemoryException or StackOverflowException. StackOverflow happens when "Composite" pattern recursively walks through hierarchy.

Post a Comment for "How Many Viewgroup (linearlayout, Relative, Grid, Etc..) Considered Too Many?"