Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2364b09 authored by Chris Yerga's avatar Chris Yerga Committed by Android (Google) Code Review
Browse files

Merge "Fix content width calculation for Spinner control. The width of the...

Merge "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." into honeycomb
parents adee6b35 efd0811a
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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,6 +634,7 @@ 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;
        }