I have created an android mobile application and i have thoroughly clean everything in the xml file of the application but there are 2 warnings that i can get rid of one is activity_main.xml has more than 80 views, bad for performance
and the other is Nested weights are bad for performance
i have an option to suppress those warnings but i'm not sure if its the right thing to do. i would like to know the draw back of these warning and if it is ok if i just suppress these warning or i need to eliminate these warning

- 1,619
- 7
- 33
- 67
-
1Nested layout can cause OutOfMemory exception. – Mar 18 '14 at 04:42
-
1Check this: http://stackoverflow.com/questions/10313496/enhance-app-performance-with-more-than-80-views-on-a-layout – Lokesh Mar 18 '14 at 04:44
-
i see so if i suppress the warning it may cause my program to crash? and i suppose same goes for the other warning?thank you mate i been looking for drawback on net but i can find answer all they give are alternative to remove the warning but they dont explain what the drawbacks will be – Giant Mar 18 '14 at 04:44
2 Answers
Two thing can happen when you are using nested layout
StackOverFlow Exception
and OutOfMemory
exception. Please refer to this Stackoverflow: Caused by nested views?. You should optimize your layout you can refer to this Optimizing Layout Hierarchies.

- 1
- 1
has more than 80 views, bad for performance:
User interface performance is directly related to (among other things) the complexity of the View hierarchy being displayed. This warning message is simply letting you know that you have a lot of Views defined in this layout and that it could lead to UI performance problems. The solution is to look at your layout and considering how you can simplify the View hierarchy to achieve the desired results with fewer Views. Or, alternatively, you can take this warning with a grain of salt and just test to verify whether performance is acceptable for your layout on the device(s) that you plan to support.
Nested weights are bad for performance because:
Layout weights require a widget to be measured twice. When a LinearLayout with non-zero weights is nested inside another LinearLayout with non-zero weights, then the number of measurements increase exponentially.
It's always better to use RelativeLayouts and adjust your view according to the places of other views without using specific dpi values.

- 5,180
- 4
- 27
- 42
-
when copying one answer from other you should mention the real attribute. I think the second part of your answer is copied from [Why are nested weights bad for performance? Alternatives?](http://stackoverflow.com/questions/9430764/why-are-nested-weights-bad-for-performance-alternatives/9431087#9431087) – Mar 18 '14 at 05:29