问题
I am using a Spinner in my app. I used the basic spinner and this is my code:`
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SpinnerSpinnerTheme"
android:spinnerMode="dropdown"
android:layout_gravity="center_vertical"
android:id="@+id/hj_order_date_spinner"
/>`
and this is how i instantiated in my activity
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.hj_spinner_items,android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dateSpinner.setPrompt("Sort By");
dateSpinner.setAdapter(adapter);
This works fine in android 4.4.4 but on Nexus 5(using Lollipop) the drop down list/Popup changes it's position and hides the "Sort By" bar or the original spinner. Can anyone provide any insight as to what might be the issue?
回答1:
You can specify whether the spinner drop-down should overlap the anchor by using the android:overlapAnchor
attribute. When using the Material spinner style, this attribute defaults to true
.
<Spinner
...
android:overlapAnchor="false" />
来源:https://stackoverflow.com/questions/28924230/spinner-drop-down-popup-position-changes-in-nexus-5-android-5-0