How can I set the width or height of a spinner programmatically from java?

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list_r); adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); Spinner spinner = new Spinner(this); spinner.setAdapter(adapter); spinner.setPrompt("Список"); spinner.setSelection(1); setContentView(spinner); 

Image as I have

    1 answer 1

    You need to write your own class Spinner successor and overload the Spinner.onMeasure() method

    Just need to be very careful and carefully read the documentation . The method is capricious and you can easily fly through the expedition.