Variations of this questions are already available, but I didn't found exact duplicate. So here is my question. I want to have full width dropdown + dropdown icon in the android spinner.
I've tried with wrapping it in relative layout, then since spinner doesn't have the full width so the dropdown items. Probably relative layout with imageview will work, but I am looking for more clean solution. Below is the one with relative view approach.
I've tried with setting background drawable with dropdown icon bitmap, then it works but since dropdown item goes full width, icon cannot be seen. Below is the result + code. As you can see 2nd spinner doesn't have items, so it shows the icon.
Spinner spinner = new Spinner(ctx);
LinearLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.bottomMargin = dpToPx(10);
spinner.setLayoutParams(layoutParams);
spinner.setAdapter(new ArrayAdapter<>(ctx, R.layout.spinner_dropdown, values));
spinner.setBackgroundResource(R.drawable.spinner_background);
How can I achieve below result? I want to do this programatically.