11

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" />

Houssem
  • 2,069
  • 3
  • 27
  • 42

2 Answers2

2

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

Community
  • 1
  • 1
IZI_Shadow_IZI
  • 1,921
  • 4
  • 30
  • 59
  • This is right solution, although it looks like while using Spinner width wrap_content it does not work. It does work only with weight, dp length or match_parent, – Darek Deoniziak Feb 24 '16 at 09:55
0

android:textDirection="rtl"

AsAd KhAn
  • 11
  • 3