diff options
author | 2011-01-17 00:30:08 -0800 | |
---|---|---|
committer | 2011-01-17 00:30:08 -0800 | |
commit | efd0811a31e79aa1d3ee6fcaf8d79304872fcc5e (patch) | |
tree | 70862b78c2e5819a715dec9fb36e767f9cccde2d | |
parent | 717143ca79ccccc8565117dfebcf9c6558d34e5b (diff) |
Fix content width calculation for Spinner control.
The width of the dropdown was only taking into account
the width of the items and not background padding.
Change-Id: If27291c96191d4ac1f3e9200c6f6f585a19008c3
-rw-r--r-- | core/java/android/widget/Spinner.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index 010262823109..0baddcb97501 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -23,6 +23,8 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.res.TypedArray; import android.database.DataSetObserver; +import android.graphics.drawable.Drawable; +import android.graphics.Rect; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.Gravity; @@ -632,7 +634,8 @@ public class Spinner extends AbsSpinner implements OnClickListener { private class DropdownPopup extends ListPopupWindow implements SpinnerPopup { private CharSequence mHintText; private int mPopupMaxWidth; - + private Rect mTempRect = new Rect(); + public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) { super(context, attrs, 0, defStyleRes); @@ -699,6 +702,14 @@ public class Spinner extends AbsSpinner implements OnClickListener { itemView.measure(widthMeasureSpec, heightMeasureSpec); width = Math.max(width, itemView.getMeasuredWidth()); } + + // Add background padding to measured width + Drawable popupBackground = getBackground(); + if (popupBackground != null) { + popupBackground.getPadding(mTempRect); + width += mTempRect.left + mTempRect.right; + } + return width; } |