Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top