From 189ee18d6c6483ad63cc864267328259e2e00b95 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 2 Dec 2010 21:48:53 -0800 Subject: Implement smarter sizing of WRAP_CONTENT windows. This extends the view hierarchy's measure pass to allow view to propagate up to their parent additional information besides just their measured size. They can now report that their measured width and/or height should be larger than the size their parent is limiting them to (even though by definition they need to contrain their reported measurements to the limits imposed by the parent). ViewRoot uses this information to determine if it should remeasure the window with a larger size limit to try to make it fit. Change-Id: I90af3b7a8ec45d0a5c003fb009857025209d83eb --- core/java/android/widget/FrameLayout.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/java/android/widget/FrameLayout.java') diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index bcab7a9..940fec1 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -248,6 +248,7 @@ public class FrameLayout extends ViewGroup { int maxHeight = 0; int maxWidth = 0; + int childState = 0; // Find rightmost and bottommost child for (int i = 0; i < count; i++) { @@ -256,6 +257,7 @@ public class FrameLayout extends ViewGroup { measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0); maxWidth = Math.max(maxWidth, child.getMeasuredWidth()); maxHeight = Math.max(maxHeight, child.getMeasuredHeight()); + childState = combineMeasuredStates(childState, child.getMeasuredState()); } } @@ -274,8 +276,9 @@ public class FrameLayout extends ViewGroup { maxWidth = Math.max(maxWidth, drawable.getMinimumWidth()); } - setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec), - resolveSize(maxHeight, heightMeasureSpec)); + setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState), + resolveSizeAndState(maxHeight, heightMeasureSpec, + childState<