androidperformancememorylayoutview-hierarchy

android consolidating views in include statements, improve performance?


I am optimizing my android layouts. One suggestion I got was to re-use layouts in include statements. Although I understand the utility of this, kind of like object orientated views, but does it dramatically improve rendering time? Does it dramatically reduce memory footprint? Does it keep the view hierarchy smaller?

I wrote this assuming there was a definite answer to this, instead of a discussion

thanks for any insight!


Solution

  • Does it dramatically reduce memory footprint?

    No. Here's a view that includes two views with the same content. While the views are the same, each item in the view must be presented as a separate instance since a developer might want to select it using R.id.identifier and change its content. Practically, lets say you include a header for your app in 2 different views. The header's contents need not be the same in each view. Since the instances are different there is no savings in memory.

    screenshot

    does it dramatically improve rendering time?

    Not that I've noticed. Any gain you get here is likely to be minimal.

    Here is a related link on performance optimization on Android in case you've not seen it already -> http://developer.android.com/training/articles/perf-tips.html