summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-04-24 09:50:03 -0400
committerChris Wren <cwren@android.com>2012-04-24 16:14:31 -0400
commit54dfa5d90e49037eba05f5278076b45428b2bd11 (patch)
treefc4d22a42aae3315ee966bd04b492ac6cb752881 /core/java/com
parent57a6e14e576f7f08001027cce67955e9820a726f (diff)
downloadframeworks_base-54dfa5d90e49037eba05f5278076b45428b2bd11.zip
frameworks_base-54dfa5d90e49037eba05f5278076b45428b2bd11.tar.gz
frameworks_base-54dfa5d90e49037eba05f5278076b45428b2bd11.tar.bz2
Don't allow children of a SizeAdaptiveLayout to measure outside their declared range of valid sizes.
Bug: 6377749 Change-Id: Ie706006eee9c0ed8dda468212a652941b8e20be0
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/widget/SizeAdaptiveLayout.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/core/java/com/android/internal/widget/SizeAdaptiveLayout.java b/core/java/com/android/internal/widget/SizeAdaptiveLayout.java
index 0a99f17..bbf5509 100644
--- a/core/java/com/android/internal/widget/SizeAdaptiveLayout.java
+++ b/core/java/com/android/internal/widget/SizeAdaptiveLayout.java
@@ -16,6 +16,8 @@
package com.android.internal.widget;
+import java.lang.Math;
+
import com.android.internal.R;
import android.animation.Animator;
@@ -157,9 +159,29 @@ public class SizeAdaptiveLayout extends ViewGroup {
int childState = combineMeasuredStates(0, model.getMeasuredState());
if (DEBUG) Log.d(TAG, "measured child at: " + childHeight);
int resolvedWidth = resolveSizeAndState(childWidth, widthMeasureSpec, childState);
- int resolvedheight = resolveSizeAndState(childHeight, heightMeasureSpec, childState);
- setMeasuredDimension(resolvedWidth, resolvedheight);
- if (DEBUG) Log.d(TAG, "resolved to: " + resolvedheight);
+ int resolvedHeight = resolveSizeAndState(childHeight, heightMeasureSpec, childState);
+ if (DEBUG) Log.d(TAG, "resolved to: " + resolvedHeight);
+ int boundedHeight = clampSizeToBounds(resolvedHeight, model);
+ if (DEBUG) Log.d(TAG, "bounded to: " + boundedHeight);
+ setMeasuredDimension(resolvedWidth, boundedHeight);
+ }
+
+ private int clampSizeToBounds(int measuredHeight, View child) {
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) child.getLayoutParams();
+ int heightIn = View.MEASURED_SIZE_MASK & measuredHeight;
+ int height = Math.max(heightIn, lp.minHeight);
+ if (lp.maxHeight != SizeAdaptiveLayout.LayoutParams.UNBOUNDED) {
+ height = Math.min(height, lp.maxHeight);
+ }
+
+ if (heightIn != height) {
+ Log.d(TAG, this + "child view " + child + " " +
+ "measured out of bounds at " + heightIn +"px " +
+ "clamped to " + height + "px");
+ }
+
+ return height;
}
//TODO extend to width and height