Spinner drop down popup position changes in Nexus 5 (android 5.0)

我与影子孤独终老i 提交于 2019-12-20 02:32:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!