12

I have this spinner and want to know how I can put border around this

    Spinner dropdown = (Spinner)findViewById(R.id.spinnerUpdateContactMethod);
    String[] items = new String[]{"1", "2", "three"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
    dropdown.setPrompt("Please select ");
    dropdown.setAdapter(adapter);

the prompt doesn't actually come up on the screen. Please could someone help me with this.

dark_illusion_909099
  • 1,067
  • 2
  • 21
  • 41

2 Answers2

23

for custom border you can create an xml file inside drawable folder

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/white_overlay_8x" />
    <corners android:radius="6dip" />
    <stroke
        android:color="@color/white"
        android:width="@dimen/dot" />

</shape>

and set

android:background=@drawable/file;

in your spinner(xml file of activity)

Karthika PB
  • 1,373
  • 9
  • 16
0

this will make quite a amount of space but not a border

dropdown.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

you can add this to your Spinner instance

Best thing would be customization in which you can do a lot more than just a border

Pankaj Nimgade
  • 4,529
  • 3
  • 20
  • 30