OSDN Git Service

Optimize layout rendering in layoutlib [DO NOT MERGE]
authorDeepanshu Gupta <deepanshu@google.com>
Tue, 21 Jan 2014 01:02:37 +0000 (17:02 -0800)
committerDeepanshu Gupta <deepanshu@google.com>
Tue, 6 May 2014 21:02:45 +0000 (14:02 -0700)
The height of a layout should be zero if it is assigned a layout_weight.
This way, the layout is measured only once and prevents spurious errors.

Bug: https://code.google.com/p/android/issues/detail?id=58398
Change-Id: If49a7480e5eb82cb86780e00f2f5b65ee053fc2a
(cherry-picked from 5712b5fc3fec0dc376e84f660f2fe0d1102c0cbb)

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java

index 7169db3..f8f348c 100644 (file)
@@ -312,7 +312,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
                 backgroundView = backgroundLayout;
                 backgroundLayout.setOrientation(LinearLayout.VERTICAL);
                 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
-                        LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+                        LayoutParams.MATCH_PARENT, 0);
                 layoutParams.weight = 1;
                 backgroundLayout.setLayoutParams(layoutParams);
                 topLayout.addView(backgroundLayout);
@@ -347,7 +347,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
                 // content frame
                 mContentRoot = new FrameLayout(context);
                 layoutParams = new LinearLayout.LayoutParams(
-                        LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+                        LayoutParams.MATCH_PARENT, 0);
                 layoutParams.weight = 1;
                 mContentRoot.setLayoutParams(layoutParams);
                 backgroundLayout.addView(mContentRoot);