Android Spinner Gravity Not working

Houssem picture Houssem · Dec 17, 2012 · Viewed 7.8k times · Source

I'm trying for days to align the text in a spinner to right, but every time I fail to do it, I tried to set Gravity to right, or ellipsize to end but nothing works and all I have is this :

enter image description here

can you please help with this issue ?

Thanks a lot.

Here's the XML :

<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal" >

<org.holoeverywhere.widget.Spinner
    android:id="@+id/spnCities"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:layout_marginRight="10dp"
    android:entries="@array/array_cities"
    android:gravity="right"/>

<TextView
    android:id="@+id/tvCities"
    android:layout_width="70dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="10dp"
    android:text="@string/city"
    android:textAppearance="?android:attr/textAppearanceSmall" />

Answer

IZI_Shadow_IZI picture IZI_Shadow_IZI · Dec 17, 2012

You probably have to use a custom view to enable this to work. Use google its your best friend...this will probably help:

Align spinner values to right instead of left