how can I change the look of a spinner's button ? For now, I just need to decrease the font size. Just the button, the list is ok. Thanks
            Asked
            
        
        
            Active
            
        
            Viewed 6,739 times
        
    3 Answers
2
            - 
                    Not the items, just the button – xain Mar 21 '11 at 19:29
 - 
                    This is right answer. Implement custom adapter and override getView. Example is here: https://gist.github.com/897233 (edited ApiDemos) – Sergey Glotov Mar 31 '11 at 20:55
 
1
            
            
        For this you need to create a new layout which defines the look of your spinner viz. spinner_item. You can use it as follows. Thus the properties like background, views include in the spinner can be changed.
 ImageSpinnerAdapter adapterForImageSpinner = new ImageSpinnerAdapter(this, true,
            spinnerData, R.layout.spinner_view, new String[] { "Name",
                    "Icon" }, new int[] {R.id.imageNameSpinner,
                    R.id.imageIconSpinner }, spinnerImages);
This will be used in the adapter as follows:
public class ImageSpinnerAdapter extends SimpleAdapter {
LayoutInflater mInflater;
private List<? extends Map<String, ?>> dataRecieved;
private int[] spinnerImagesReceived;
@SuppressWarnings("unused")
private HashMap<String, Object> data;
private boolean displayItems;
private int imageId;
private String imageText;
public ImageSpinnerAdapter(Context context, boolean displayItems,
        List<? extends Map<String, ?>> data, int resource, String[] from,
        int[] to, int[] spinnerImages) {
    super(context, data, resource, from, to);
    this.displayItems = displayItems;
    dataRecieved = data;
    mInflater = LayoutInflater.from(context);
    spinnerImagesReceived = spinnerImages;
}
@SuppressWarnings("unchecked")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.spinner_view, null);
    }
    data = (HashMap<String, Object>) getItem(position);
    if (displayItems) {
        setImageId(spinnerImagesReceived[position]);
        setImageText((String) dataRecieved.get(position).get("Name"));
    } else {
        setImageText("");
        setImageId(R.drawable.invalid);
    }
    ((ImageView) convertView.findViewById(R.id.imageIconSpinner))
    .setBackgroundResource(getImageId());
    ((TextView) convertView.findViewById(R.id.imageNameSpinner))
            .setText(getImageText());
    return convertView;
}
}
        Vicky Kapadia
        
- 6,025
 - 2
 - 24
 - 30
 
0
            
            
        If what you wanna do is change the actual spinner size, make it less tall, just use the layout_height on your xml:
android:layout_height="40dip"
Less than that, the button with the arrow won't look good.
        Horaceman
        
- 786
 - 6
 - 10