Android Spinner Gravity Not working
Asked Answered
F

2

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

Fir answered 17/12, 2012 at 16:40 Comment(3)
Could you post your xml?Extravagance
Try this #2492480Extravagance
thx Silverstorm, tried this, but this acts on the dropdown items, all I want is that view (see pic) becomes wrapped (in fact wrap_content too is not working)Fir
W
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

Wong answered 17/12, 2012 at 16:49 Comment(1)
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,Superdreadnought
T
0

android:textDirection="rtl"

Transpire answered 1/3, 2021 at 22:12 Comment(2)
Maybe you want to expand on your thought?Surety
I meant that you may want to explain that so that the Original Poster (OP) can understand what it is, how to use it, and how it will be helpful.Surety

© 2022 - 2024 — McMap. All rights reserved.