Android: nesting FrameLayouts - what is the exact performance overhead?
Asked Answered
H

0

7

In order to implement a clean architecture with separate and reusable UI components, I need to have hierarchies of nested FrameLayouts (up to 3-4 nested FrameLayouts), all of which have both layout_width and layout_height set to match_parent (the general idea behind that architecture is described in this answer).

I came to wonder if there is any noticeable performance overhead associated with this practice of nesting FrameLayouts. In order to make the question less abstract, let's discuss it in context of two concrete hierarchies: "static" hierarchy (nothing moves on the screen), and "scrollable" hierarchy (user can scroll the screen).

"Static" hierarchy:

enter image description here

once the screen containing this hierarchy is shown, nothing changes anymore.

"Scrollable" hierarchy:

enter image description here

after this hierarchy is shown on the screen, the user can scroll the inner ListView, thus requiring redraw of the innermost RelativeLayouts.

I'm not worried at all about "static" hierarchy - the overhead of nested FrameLayouts in this case is paid once and will not impact layout's performance in any noticeable way.

  • Q1: Is this assumption correct, or there are some performance-degrading scenarios which I can bump into?

What about "scrollable" layout? I wonder whether the fact that the inner ListView is wrapped in several FrameLayouts affects its scrolling performance...

  • Q2: Are outer FrameLayouts affect nested ListView scrolling performance?
  • Q3: If answer to Q2 is "yes", what is the exact overhead in "scrollable" case?
Hux answered 10/5, 2016 at 15:37 Comment(4)
That answer you linked says literally nothing about nesting viewsSporogenesis
Have you found any answers to that?Portuguese
@Portuguese , empiric answer only: used this approach in ~10 different apps and tested on low end devices, but never had issues due to additional FrameLayouts.Hux
Thank you for letting me know that. Actually I am your student and I am following your guidance regarding using MVC views. That’s why I was curious about how it would affect on performance.Portuguese

© 2022 - 2024 — McMap. All rights reserved.