2017-09-14 110 views
2

我想微调像以下图片下拉列表中,如何自定义微调框?

我下面创建这样

xml布局:

<Spinner 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="20dp" 
     android:background="@drawable/edittext_shape" 
     android:padding="10dp" 
      android:paddingLeft="4dp" 
     android:id="@+id/rol_type" 
     android:layout_marginBottom="2dp"> 

微调塑造

<?xml version="1.0" encoding="utf-8"?> 
    <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
     <item><layer-list> 
      <item><shape> 
       <gradient android:angle="90" android:startColor="@color/white" android:endColor="@color/appblue" /> 

       <stroke android:width="1dp" android:color="@color/block" /> 

       <corners android:radius="4dp" /> 

       <!-- <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />--> 
      </shape></item> 
      <item ><bitmap android:gravity="right|bottom|end" android:src="@drawable/drop_arrow" android:tint="@color/red" /> 
      </item> 
     </layer-list></item> 

    </selector> 

我的输出:

enter image description here

我想下面这样的请帮我在这种情况下:

enter image description here

+1

检查这个ANS ** ** 1 https://stackoverflow.com/questions/34322156/how-to-move-the-android-spinner -drop-down-arrow-close-to-its-text-text ** 2 ** https://stackoverflow.com/questions/28715036/spinner-with-arrow-in-left ** 3 ** https:/ /stackoverflow.com/a/41463318/7666442 –

+1

@NileshRathod谢谢您的主席下面的答案工作正常。 – Mariyappan

回答

1

试试这个: 我改变你的背景风格。 您还可以扩展这种风格并加入自己的元素https://developer.android.com/guide/topics/ui/look-and-feel/themes.html

<Spinner 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="20dp" 
    style="@android:style/Widget.Holo.Light.Spinner" 
    android:padding="10dp" 
    android:paddingLeft="4dp" 
    android:id="@+id/rol_type" 
    android:layout_marginBottom="2dp"> 
+0

雅这是工作先生非常感谢你...简单的答案,但更有效...再次感谢很多。 – Mariyappan

+1

如何更改微调框底部边界线的颜色。 – Mariyappan

+0

尝试将android:backgroudTint =“”添加到微调项目。 –