Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align spinner values to right instead of left

In spinner xml, I'm using:

 android:entries="@array/cars"

where cars is list of numeric items.

The spinner automatically align values to left, and I can't find in xml/code how to change it.

like image 640
David Avatar asked May 17 '12 04:05

David


2 Answers

You have to use a custom view here to give alignment to the Spinner values. Create a CustomView like this answer has created and add android:gravity to the TextView as right.

UPDATE:

Set the CustomView to your adapter using

adapter.setDropDownViewResource(android.R.layout.your_custom_created_view);
like image 94
Lalit Poptani Avatar answered Oct 17 '22 17:10

Lalit Poptani


You can use TextAlignment on properties and select TextEnd, or android:textAlignment="textEnd" on XML simple

like image 38
Eddy Charry Avatar answered Oct 17 '22 17:10

Eddy Charry