Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top/Bottom Padding for Spinner

How do I specify for a spinner in Android an extra padding on top/bottom of the first/last item? See sample of Goolge below (8 dp spacing). Google Simple Menu

like image 434
multiholle Avatar asked Oct 27 '15 15:10

multiholle


2 Answers

Spinner does not support multiple view types.Issue.

I suggested you using dialog for showing your list.

Edited

according to your comment resolved your problem with this question

like image 113
Mohammad Hossein Gerami Avatar answered Nov 04 '22 00:11

Mohammad Hossein Gerami


You need to create a custom adapter for you Spinner using your custom layout. Thus, you just need to provide a layout with the proper margin/paddins.

Spinner spinner = (Spinner) findViewById(R.id.myspinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.data, R.layout.spinner_item);
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinner.setAdapter(adapter);

You can find a valid example here.

like image 4
bonnyz Avatar answered Nov 04 '22 00:11

bonnyz