I am using the spinner and it opens like a dialog. I need spinner to be open like dropdown menu.
Here is the xml file
<Spinner
android:id="@+id/sp_countrycode_issue_coupon"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:layout_weight="1"
android:background="@drawable/img_small_box_green"
android:dropDownSelector="@drawable/img_small_box_green"
android:gravity="right|center"
android:textAlignment="center" />
Here is the code
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.country_code,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(R.layout.spinner_textview);
sp_country_code.setAdapter(adapter);
I posted my images bellow like my view and spinner display view. But I need the spinner to be display like the third image
Late but may be useful to other people, you can simply set the spinnerMode to dropdown:
Else, if you decided you fancied a change and wanted dialog in the future just change the mode to dialog!
in manifest file change theme to
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
and in xml file set style for spinnerstyle="@style/MyDropDownNav"
and in style file add style.For the information Dropdown spinner that you shown in Image 3 is applicable from version 3.0 and above. For previous versions like 2.2 and 2.3 it will open like dialog. It will automatically show dropdown in versions above 2.3
Styles will be automatically added if you choose android version 4.0 or above.
Refrence code
Edit
Just change the code like this: