2015-02-08 111 views
0

我想知道是否(以及如何)可以更改微调器选择器图标的图标位置。在这一点上,我已经让我的微调器的宽度匹配父(全屏),然后得到文本居中。所以在这一刻,文本居中,但选择器图标在最右边...Android微调,选择器图标位置

我真正想要的是所选项目旁边的图标。我已经添加了一张图片以供澄清。

enter image description here

预先感谢您。

编辑:我希望选择器图标始终位于所选项目的旁边,选定的项目可以是5到15个字符的变量。所以,它的位置不应该是静态的,而是动态的跟随微调的所选项目...

回答

1

选项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> 

选项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> 

可以有很多其他解决方法。

编辑

正如您在您的评论澄清,看到this answer

+0

几乎就是我要找的。应该提到我希望它遵循所选项目的长度。因为所选的项目可能是5个字符或15个字符。我希望选择器图标始终位于旁边。你的选择给它一个静态位置。但我非常期待这一步! – Serellyn 2015-02-09 12:50:44

+0

看到我的编辑结束(去http://stackoverflow.com/a/13967767/1039555) – 2015-02-09 22:18:38

+0

谢谢你的帮助:) – Serellyn 2015-02-10 11:08:23