summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/FrameLayout.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2015-06-25 12:24:27 -0700
committerAlan Viverette <alanv@google.com>2015-06-25 12:24:27 -0700
commit39fd902bdb329461f793e356306a912e1655c5c5 (patch)
treedf66dbffa82f85e8e9e19886f1f81ffe5010823a /core/java/android/widget/FrameLayout.java
parent60061c26a24f654f5a6ac599d85c3bea14ee9aff (diff)
downloadframeworks_base-39fd902bdb329461f793e356306a912e1655c5c5.zip
frameworks_base-39fd902bdb329461f793e356306a912e1655c5c5.tar.gz
frameworks_base-39fd902bdb329461f793e356306a912e1655c5c5.tar.bz2
Constrain child width and height to >= 0 in FrameLayout.onMeasure()
Bug: 22093669 Change-Id: I55e8a0289f871b73ed07f3d73e8297786f9acac1
Diffstat (limited to 'core/java/android/widget/FrameLayout.java')
-rw-r--r--core/java/android/widget/FrameLayout.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index 7ca450a..280ff15 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -230,28 +230,29 @@ public class FrameLayout extends ViewGroup {
if (count > 1) {
for (int i = 0; i < count; i++) {
final View child = mMatchParentChildren.get(i);
-
final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
- int childWidthMeasureSpec;
- int childHeightMeasureSpec;
-
+
+ final int childWidthMeasureSpec;
if (lp.width == LayoutParams.MATCH_PARENT) {
- childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() -
- getPaddingLeftWithForeground() - getPaddingRightWithForeground() -
- lp.leftMargin - lp.rightMargin,
- MeasureSpec.EXACTLY);
+ final int width = Math.max(0, getMeasuredWidth()
+ - getPaddingLeftWithForeground() - getPaddingRightWithForeground()
+ - lp.leftMargin - lp.rightMargin);
+ childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
+ width, MeasureSpec.EXACTLY);
} else {
childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
getPaddingLeftWithForeground() + getPaddingRightWithForeground() +
lp.leftMargin + lp.rightMargin,
lp.width);
}
-
+
+ final int childHeightMeasureSpec;
if (lp.height == LayoutParams.MATCH_PARENT) {
- childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() -
- getPaddingTopWithForeground() - getPaddingBottomWithForeground() -
- lp.topMargin - lp.bottomMargin,
- MeasureSpec.EXACTLY);
+ final int height = Math.max(0, getMeasuredHeight()
+ - getPaddingTopWithForeground() - getPaddingBottomWithForeground()
+ - lp.topMargin - lp.bottomMargin);
+ childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
+ height, MeasureSpec.EXACTLY);
} else {
childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
getPaddingTopWithForeground() + getPaddingBottomWithForeground() +