0

I wonder if (and how) it's possible to change the icon location of the Spinner's selector icon. At this point I've got my spinner's width matching the parent (full screen) and then got the text centered. So at this moment, the text is centered but the selector icon is at the far right...

What I really want is the icon right next the the selected item. I've added a picture for clarification.

enter image description here

Thank you in advance.

Edit: I'd like the selector icon to be always next to selected item, the selected item can be variable from 5 to 15 characters. So the position of it should not be static but dynamic to follow the selected item of the spinner...

Serellyn
  • 405
  • 1
  • 9
  • 26

1 Answers1

1

Option 1:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="48dp"
        android:layout_marginRight="48dp" />

</RelativeLayout>

Option 2:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:visibility="invisible" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="4" />

    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:visibility="invisible" />
</LinearLayout>

There can be a lot of other workarounds.

Edit

As you clarified in your comment, see this answer

Community
  • 1
  • 1
Kartik
  • 7,677
  • 4
  • 28
  • 50
  • Almost what I'm looking for. Should've mentioned that I would like it to follow the length of the item selected. Because the item selected could be 5 characters or 15 characters. I would like the selector icon to always be next to it. Your options give it a static location. But I'm greatful for the step ahead! – Serellyn Feb 09 '15 at 12:50