summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/RelativeLayout.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2015-06-24 17:03:48 -0700
committerAlan Viverette <alanv@google.com>2015-06-24 17:03:48 -0700
commit39310d36069d4b3f7e05dbdd8ba24ea8c4b679c0 (patch)
treea8f5cf849ae04bb6e2a9a3ad6c40435c1d089a93 /core/java/android/widget/RelativeLayout.java
parentcede20a7c273279a9bc51750bdd99c1383816e3e (diff)
downloadframeworks_base-39310d36069d4b3f7e05dbdd8ba24ea8c4b679c0.zip
frameworks_base-39310d36069d4b3f7e05dbdd8ba24ea8c4b679c0.tar.gz
frameworks_base-39310d36069d4b3f7e05dbdd8ba24ea8c4b679c0.tar.bz2
Avoid negative childSpecSize in RelativeLayout
Bug: 22071351 Change-Id: I951fd7c7973c49581d3ea30bae64d6c20bc362be
Diffstat (limited to 'core/java/android/widget/RelativeLayout.java')
-rw-r--r--core/java/android/widget/RelativeLayout.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index 339038e..dac02fa 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -763,19 +763,19 @@ public class RelativeLayout extends ViewGroup {
}
// Figure out maximum size available to this view
- int maxAvailable = tempEnd - tempStart;
+ final int maxAvailable = tempEnd - tempStart;
if (childStart != VALUE_NOT_SET && childEnd != VALUE_NOT_SET) {
- // Constraints fixed both edges, so child must be an exact size
+ // Constraints fixed both edges, so child must be an exact size.
childSpecMode = MeasureSpec.EXACTLY;
- childSpecSize = maxAvailable;
+ childSpecSize = Math.max(0, maxAvailable);
} else {
if (childSize >= 0) {
- // Child wanted an exact size. Give as much as possible
+ // Child wanted an exact size. Give as much as possible.
childSpecMode = MeasureSpec.EXACTLY;
if (maxAvailable >= 0) {
- // We have a maxmum size in this dimension.
+ // We have a maximum size in this dimension.
childSpecSize = Math.min(maxAvailable, childSize);
} else {
// We can grow in this dimension.
@@ -783,20 +783,19 @@ public class RelativeLayout extends ViewGroup {
}
} else if (childSize == LayoutParams.MATCH_PARENT) {
// Child wanted to be as big as possible. Give all available
- // space
+ // space.
childSpecMode = MeasureSpec.EXACTLY;
- childSpecSize = maxAvailable;
+ childSpecSize = Math.max(0, maxAvailable);
} else if (childSize == LayoutParams.WRAP_CONTENT) {
- // Child wants to wrap content. Use AT_MOST
- // to communicate available space if we know
- // our max size
+ // Child wants to wrap content. Use AT_MOST to communicate
+ // available space if we know our max size.
if (maxAvailable >= 0) {
// We have a maximum size in this dimension.
childSpecMode = MeasureSpec.AT_MOST;
childSpecSize = maxAvailable;
} else {
// We can grow in this dimension. Child can be as big as it
- // wants
+ // wants.
childSpecMode = MeasureSpec.UNSPECIFIED;
childSpecSize = 0;
}