Question

When designing Android layouts there is often a question - should you sacrifice readability for performance? For example, you can put the same components into several nested layouts or one complex RelativeLayout. My understanding is, only in the cases when there is excess nesting (more than 8-10 levels), or this is a repeating element in an adapter, you should try to flatten the hierarchy by using RelativeLayout. Maybe I'm wrong and you should by default prefer complex RelativeLayouts over a combination of Frame/Linear/RelativeLayouts, because a new level in view hierarchy is substantial for performance and memory use?

Was it helpful?

Solution

I would agree that it is somewhat philosophical.

That being said, considering how important a responsive UI is on an android application and how often an XML layout may be inflated, I would err on the side of performance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top