diff options
author | Adam Powell <adamp@google.com> | 2012-03-08 12:01:16 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2012-03-08 12:19:31 -0800 |
commit | 7507d3d31cb3d0ca190efc9d6b7ead5d6336f8d6 (patch) | |
tree | 94222352e79db8d0a3b1399bb609772d63422577 /core/java/android/widget | |
parent | 1881f27b9ddf9d93d6b4b8560faef51de91a7b55 (diff) | |
download | frameworks_base-7507d3d31cb3d0ca190efc9d6b7ead5d6336f8d6.zip frameworks_base-7507d3d31cb3d0ca190efc9d6b7ead5d6336f8d6.tar.gz frameworks_base-7507d3d31cb3d0ca190efc9d6b7ead5d6336f8d6.tar.bz2 |
Fix measurement issues with Spinner and ListPopupWindow
Bug 6132826 - make sure that our speculative measurement of list items
uses an accurate width MeasureSpec. This bug would sometimes affect
window sizing when measuring height if content could wrap in the
presence of restricted width.
Change-Id: Ie28573e952cac3dfa2b95e4691758c72f26b8fd9
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/ListPopupWindow.java | 22 | ||||
-rw-r--r-- | core/java/android/widget/Spinner.java | 1 |
2 files changed, 21 insertions, 2 deletions
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java index 5c97593..f4d5d74 100644 --- a/core/java/android/widget/ListPopupWindow.java +++ b/core/java/android/widget/ListPopupWindow.java @@ -1080,6 +1080,8 @@ public class ListPopupWindow { if (!mDropDownVerticalOffsetSet) { mDropDownVerticalOffset = -mTempRect.top; } + } else { + mTempRect.setEmpty(); } // Max height available on the screen for a popup. @@ -1092,7 +1094,25 @@ public class ListPopupWindow { return maxHeight + padding; } - final int listContent = mDropDownList.measureHeightOfChildren(MeasureSpec.UNSPECIFIED, + final int childWidthSpec; + switch (mDropDownWidth) { + case ViewGroup.LayoutParams.WRAP_CONTENT: + childWidthSpec = MeasureSpec.makeMeasureSpec( + mContext.getResources().getDisplayMetrics().widthPixels - + (mTempRect.left + mTempRect.right), + MeasureSpec.AT_MOST); + break; + case ViewGroup.LayoutParams.MATCH_PARENT: + childWidthSpec = MeasureSpec.makeMeasureSpec( + mContext.getResources().getDisplayMetrics().widthPixels - + (mTempRect.left + mTempRect.right), + MeasureSpec.EXACTLY); + break; + default: + childWidthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.EXACTLY); + break; + } + final int listContent = mDropDownList.measureHeightOfChildren(childWidthSpec, 0, ListView.NO_POSITION, maxHeight - otherHeights, -1); // add padding only if the list has items in it, that way we don't show // the popup if it is not needed diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index 89c506f..6540613 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -26,7 +26,6 @@ import android.database.DataSetObserver; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; -import android.util.DisplayMetrics; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; |