Loading core/java/android/widget/ListPopupWindow.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -449,6 +449,8 @@ public class ListPopupWindow { if (popupBackground != null) { if (popupBackground != null) { popupBackground.getPadding(mTempRect); popupBackground.getPadding(mTempRect); mDropDownWidth = mTempRect.left + mTempRect.right + width; mDropDownWidth = mTempRect.left + mTempRect.right + width; } else { setWidth(width); } } } } Loading core/java/android/widget/PopupWindow.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -1065,9 +1065,10 @@ public class PopupWindow { private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams p, private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams p, int xoff, int yoff) { int xoff, int yoff) { final int anchorHeight = anchor.getHeight(); anchor.getLocationInWindow(mDrawingLocation); anchor.getLocationInWindow(mDrawingLocation); p.x = mDrawingLocation[0] + xoff; p.x = mDrawingLocation[0] + xoff; p.y = mDrawingLocation[1] + anchor.getHeight() + yoff; p.y = mDrawingLocation[1] + anchorHeight + yoff; boolean onTop = false; boolean onTop = false; Loading @@ -1077,8 +1078,11 @@ public class PopupWindow { final Rect displayFrame = new Rect(); final Rect displayFrame = new Rect(); anchor.getWindowVisibleDisplayFrame(displayFrame); anchor.getWindowVisibleDisplayFrame(displayFrame); int screenY = mScreenLocation[1] + anchorHeight + yoff; final View root = anchor.getRootView(); final View root = anchor.getRootView(); if (p.y + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth() > 0) { if (screenY + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth() > 0) { // if the drop down disappears at the bottom of the screen. we try to // if the drop down disappears at the bottom of the screen. we try to // scroll a parent scrollview or move the drop down back up on top of // scroll a parent scrollview or move the drop down back up on top of // the edit box // the edit box Loading core/java/android/widget/Spinner.java +17 −4 Original line number Original line Diff line number Diff line Loading @@ -714,14 +714,27 @@ public class Spinner extends AbsSpinner implements OnClickListener { @Override @Override public void show() { public void show() { final int spinnerPaddingLeft = Spinner.this.getPaddingLeft(); if (mDropDownWidth == WRAP_CONTENT) { if (mDropDownWidth == WRAP_CONTENT) { setWidth(Math.max(measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), final int spinnerWidth = Spinner.this.getWidth(); Spinner.this.getWidth())); final int spinnerPaddingRight = Spinner.this.getPaddingRight(); setContentWidth(Math.max( measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight)); } else if (mDropDownWidth == MATCH_PARENT) { } else if (mDropDownWidth == MATCH_PARENT) { setWidth(Spinner.this.getWidth()); final int spinnerWidth = Spinner.this.getWidth(); final int spinnerPaddingRight = Spinner.this.getPaddingRight(); setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight); } else { } else { setWidth(mDropDownWidth); setContentWidth(mDropDownWidth); } } final Drawable background = getBackground(); int bgOffset = 0; if (background != null) { background.getPadding(mTempRect); bgOffset = -mTempRect.left; } setHorizontalOffset(bgOffset + spinnerPaddingLeft); setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED); setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED); super.show(); super.show(); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); Loading core/res/res/values/styles.xml +4 −0 Original line number Original line Diff line number Diff line Loading @@ -1772,6 +1772,8 @@ please see styles_device_defaults.xml. <style name="Widget.Holo.DropDownItem" parent="Widget.DropDownItem"> <style name="Widget.Holo.DropDownItem" parent="Widget.DropDownItem"> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.DropDownItem</item> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.DropDownItem</item> <item name="android:paddingLeft">8dp</item> <item name="android:paddingRight">8dp</item> </style> </style> <style name="Widget.Holo.DropDownItem.Spinner"> <style name="Widget.Holo.DropDownItem.Spinner"> Loading @@ -1779,6 +1781,8 @@ please see styles_device_defaults.xml. <style name="Widget.Holo.TextView.SpinnerItem" parent="Widget.TextView.SpinnerItem"> <style name="Widget.Holo.TextView.SpinnerItem" parent="Widget.TextView.SpinnerItem"> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.TextView.SpinnerItem</item> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.TextView.SpinnerItem</item> <item name="android:paddingLeft">8dp</item> <item name="android:paddingRight">8dp</item> </style> </style> <style name="Widget.Holo.KeyboardView" parent="Widget.KeyboardView"> <style name="Widget.Holo.KeyboardView" parent="Widget.KeyboardView"> Loading Loading
core/java/android/widget/ListPopupWindow.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -449,6 +449,8 @@ public class ListPopupWindow { if (popupBackground != null) { if (popupBackground != null) { popupBackground.getPadding(mTempRect); popupBackground.getPadding(mTempRect); mDropDownWidth = mTempRect.left + mTempRect.right + width; mDropDownWidth = mTempRect.left + mTempRect.right + width; } else { setWidth(width); } } } } Loading
core/java/android/widget/PopupWindow.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -1065,9 +1065,10 @@ public class PopupWindow { private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams p, private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams p, int xoff, int yoff) { int xoff, int yoff) { final int anchorHeight = anchor.getHeight(); anchor.getLocationInWindow(mDrawingLocation); anchor.getLocationInWindow(mDrawingLocation); p.x = mDrawingLocation[0] + xoff; p.x = mDrawingLocation[0] + xoff; p.y = mDrawingLocation[1] + anchor.getHeight() + yoff; p.y = mDrawingLocation[1] + anchorHeight + yoff; boolean onTop = false; boolean onTop = false; Loading @@ -1077,8 +1078,11 @@ public class PopupWindow { final Rect displayFrame = new Rect(); final Rect displayFrame = new Rect(); anchor.getWindowVisibleDisplayFrame(displayFrame); anchor.getWindowVisibleDisplayFrame(displayFrame); int screenY = mScreenLocation[1] + anchorHeight + yoff; final View root = anchor.getRootView(); final View root = anchor.getRootView(); if (p.y + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth() > 0) { if (screenY + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth() > 0) { // if the drop down disappears at the bottom of the screen. we try to // if the drop down disappears at the bottom of the screen. we try to // scroll a parent scrollview or move the drop down back up on top of // scroll a parent scrollview or move the drop down back up on top of // the edit box // the edit box Loading
core/java/android/widget/Spinner.java +17 −4 Original line number Original line Diff line number Diff line Loading @@ -714,14 +714,27 @@ public class Spinner extends AbsSpinner implements OnClickListener { @Override @Override public void show() { public void show() { final int spinnerPaddingLeft = Spinner.this.getPaddingLeft(); if (mDropDownWidth == WRAP_CONTENT) { if (mDropDownWidth == WRAP_CONTENT) { setWidth(Math.max(measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), final int spinnerWidth = Spinner.this.getWidth(); Spinner.this.getWidth())); final int spinnerPaddingRight = Spinner.this.getPaddingRight(); setContentWidth(Math.max( measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight)); } else if (mDropDownWidth == MATCH_PARENT) { } else if (mDropDownWidth == MATCH_PARENT) { setWidth(Spinner.this.getWidth()); final int spinnerWidth = Spinner.this.getWidth(); final int spinnerPaddingRight = Spinner.this.getPaddingRight(); setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight); } else { } else { setWidth(mDropDownWidth); setContentWidth(mDropDownWidth); } } final Drawable background = getBackground(); int bgOffset = 0; if (background != null) { background.getPadding(mTempRect); bgOffset = -mTempRect.left; } setHorizontalOffset(bgOffset + spinnerPaddingLeft); setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED); setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED); super.show(); super.show(); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); Loading
core/res/res/values/styles.xml +4 −0 Original line number Original line Diff line number Diff line Loading @@ -1772,6 +1772,8 @@ please see styles_device_defaults.xml. <style name="Widget.Holo.DropDownItem" parent="Widget.DropDownItem"> <style name="Widget.Holo.DropDownItem" parent="Widget.DropDownItem"> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.DropDownItem</item> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.DropDownItem</item> <item name="android:paddingLeft">8dp</item> <item name="android:paddingRight">8dp</item> </style> </style> <style name="Widget.Holo.DropDownItem.Spinner"> <style name="Widget.Holo.DropDownItem.Spinner"> Loading @@ -1779,6 +1781,8 @@ please see styles_device_defaults.xml. <style name="Widget.Holo.TextView.SpinnerItem" parent="Widget.TextView.SpinnerItem"> <style name="Widget.Holo.TextView.SpinnerItem" parent="Widget.TextView.SpinnerItem"> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.TextView.SpinnerItem</item> <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.TextView.SpinnerItem</item> <item name="android:paddingLeft">8dp</item> <item name="android:paddingRight">8dp</item> </style> </style> <style name="Widget.Holo.KeyboardView" parent="Widget.KeyboardView"> <style name="Widget.Holo.KeyboardView" parent="Widget.KeyboardView"> Loading