summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-09-26 15:21:39 -0700
committerAdam Powell <adamp@google.com>2012-09-28 15:52:36 -0700
commitd5edc7721791ad807b9a8fbd923b8d6e73c399cc (patch)
tree34fd559e27573e2d3f624c0438ec3c2abdccc9ef /core/java
parent59adf04ab391d5cbfb8d031eff39937aebabade1 (diff)
downloadframeworks_base-d5edc7721791ad807b9a8fbd923b8d6e73c399cc.zip
frameworks_base-d5edc7721791ad807b9a8fbd923b8d6e73c399cc.tar.gz
frameworks_base-d5edc7721791ad807b9a8fbd923b8d6e73c399cc.tar.bz2
Fix adjustViewBounds handling for ImageView
When computing the adjusted view bounds, don't constrain the dimensions by the original estimate if the opposite dimension has a fixed size. This can result in the view never getting properly enlarged. Also fix a long-standing bug in MeasureSpec.makeMeasureSpec where oversized or negative values could result in broken packed values. Bug 7240251 Change-Id: I359d108ff52b6f3b5c4bf393d2271d28999c0127
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/View.java2
-rw-r--r--core/java/android/widget/ImageView.java13
2 files changed, 14 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f9ff865..1c12738 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -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);
}
/**
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 87396fb..1d465ce 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -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;
}