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>
Fri, 28 Mar 2014 21:21:10 +0000 (14:21 -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 35d56c0d67537e56fafebd8edf790026644fe8de)

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

index 9ddbbf1..7e09195 100644 (file)
@@ -335,7 +335,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);
@@ -370,7 +370,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);