Merge "Fix adjustViewBounds handling for ImageView" into jb-mr1-dev

This commit is contained in:
Adam Powell
2012-09-28 16:15:35 -07:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 1 deletions

View File

@@ -17208,7 +17208,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @return the measure specification based on size and mode
*/
public static int makeMeasureSpec(int size, int mode) {
return size + mode;
return (size & ~MODE_MASK) | (mode & MODE_MASK);
}
/**

View File

@@ -789,6 +789,12 @@ public class ImageView extends View {
if (resizeWidth) {
int newWidth = (int)(desiredAspect * (heightSize - ptop - pbottom)) +
pleft + pright;
// Allow the width to outgrow its original estimate if height is fixed.
if (!resizeHeight) {
widthSize = resolveAdjustedSize(newWidth, mMaxWidth, widthMeasureSpec);
}
if (newWidth <= widthSize) {
widthSize = newWidth;
done = true;
@@ -799,6 +805,13 @@ public class ImageView extends View {
if (!done && resizeHeight) {
int newHeight = (int)((widthSize - pleft - pright) / desiredAspect) +
ptop + pbottom;
// Allow the height to outgrow its original estimate if width is fixed.
if (!resizeWidth) {
heightSize = resolveAdjustedSize(newHeight, mMaxHeight,
heightMeasureSpec);
}
if (newHeight <= heightSize) {
heightSize = newHeight;
}