Layout Weight Warning Nested Weight Bad Performance
Solution 1:
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.
courtesy: Why are nested weights bad for performance? Alternatives?
Solution 2:
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.
Refer: http://developer.android.com/resources/articles/layout-tricks-efficiency.html
You can use a RelativeLayout in most cases to avoid such expensive measurements. In a RelativeLayout, views are aligned with their parent, with the RelativeLayout itself, or with other views.
To clearly understand how the views are positioned with respect to each other, a wireframe of the layout can be captured by using HierarchyViewer perspective of Android SDK.
Solution 3:
Try removing the android:weightSum="10"
from the linear layout, also remove android:layout_weight="1"
Now you see that the warning has disappeared!
Make sure to keep the weights in the buttons and other stuff in linear layouts!
I hope that this may solve your problem :)
Post a Comment for "Layout Weight Warning Nested Weight Bad Performance"