am 10bf27e2: Merge "Avoid negative childSpecSize in RelativeLayout" into mnc-dev
* commit '10bf27e2c90f05a8acad3cf902a9bf3ab8dbcca3': Avoid negative childSpecSize in RelativeLayout
This commit is contained in:
@@ -763,19 +763,19 @@ public class RelativeLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Figure out maximum size available to this view
|
// 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) {
|
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;
|
childSpecMode = MeasureSpec.EXACTLY;
|
||||||
childSpecSize = maxAvailable;
|
childSpecSize = Math.max(0, maxAvailable);
|
||||||
} else {
|
} else {
|
||||||
if (childSize >= 0) {
|
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;
|
childSpecMode = MeasureSpec.EXACTLY;
|
||||||
|
|
||||||
if (maxAvailable >= 0) {
|
if (maxAvailable >= 0) {
|
||||||
// We have a maxmum size in this dimension.
|
// We have a maximum size in this dimension.
|
||||||
childSpecSize = Math.min(maxAvailable, childSize);
|
childSpecSize = Math.min(maxAvailable, childSize);
|
||||||
} else {
|
} else {
|
||||||
// We can grow in this dimension.
|
// We can grow in this dimension.
|
||||||
@@ -783,20 +783,19 @@ public class RelativeLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
} else if (childSize == LayoutParams.MATCH_PARENT) {
|
} else if (childSize == LayoutParams.MATCH_PARENT) {
|
||||||
// Child wanted to be as big as possible. Give all available
|
// Child wanted to be as big as possible. Give all available
|
||||||
// space
|
// space.
|
||||||
childSpecMode = MeasureSpec.EXACTLY;
|
childSpecMode = MeasureSpec.EXACTLY;
|
||||||
childSpecSize = maxAvailable;
|
childSpecSize = Math.max(0, maxAvailable);
|
||||||
} else if (childSize == LayoutParams.WRAP_CONTENT) {
|
} else if (childSize == LayoutParams.WRAP_CONTENT) {
|
||||||
// Child wants to wrap content. Use AT_MOST
|
// Child wants to wrap content. Use AT_MOST to communicate
|
||||||
// to communicate available space if we know
|
// available space if we know our max size.
|
||||||
// our max size
|
|
||||||
if (maxAvailable >= 0) {
|
if (maxAvailable >= 0) {
|
||||||
// We have a maximum size in this dimension.
|
// We have a maximum size in this dimension.
|
||||||
childSpecMode = MeasureSpec.AT_MOST;
|
childSpecMode = MeasureSpec.AT_MOST;
|
||||||
childSpecSize = maxAvailable;
|
childSpecSize = maxAvailable;
|
||||||
} else {
|
} else {
|
||||||
// We can grow in this dimension. Child can be as big as it
|
// We can grow in this dimension. Child can be as big as it
|
||||||
// wants
|
// wants.
|
||||||
childSpecMode = MeasureSpec.UNSPECIFIED;
|
childSpecMode = MeasureSpec.UNSPECIFIED;
|
||||||
childSpecSize = 0;
|
childSpecSize = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user