Remove Spacing or Padding in android Spinner

BomberBus picture BomberBus · Mar 20, 2015 · Viewed 30.9k times · Source

I'm using android spinner and edittext from support lib v21. I would like to align text to left the same like edittext as shown in figure. But, deafult spinner include spacing or padding. So, I would like to remove it to align text to left. Please help how to remove it.

enter image description here

Answer

Chan Chun Him picture Chan Chun Him · Oct 26, 2015

In your SpinnerAdapter:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        view.setPadding(0, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
        return view;
}