2016-07-25 14 views
0

Hier hinzuzufügen ist mein Code für spinner_style.xmlWie Styling auf den Android Spinner

<item><layer-list> 
    <item><shape> 
     <gradient android:angle="90" android:endColor="#B3BBCC" android:startColor="#E8EBEF" android:type="linear" /> 

     <stroke android:width="1dp" android:color="#000000" /> 

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

     <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" /> 
    </shape></item> 
    <item ><bitmap android:gravity="bottom|right" android:src="@drawable/spinner_arrow" /> 
    </item> 
</layer-list></item> 

style.xml

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 
<style name="spinner_style"> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:background">@drawable/spinner_style</item> 
    <item name="android:layout_margin">10dp</item> 
    <item name="android:paddingLeft">8dp</item> 
    <item name="android:paddingRight">20dp</item> 
    <item name="android:paddingTop">5dp</item> 
    <item name="android:paddingBottom">5dp</item> 
    <item name="android:popupBackground">#DFFFFFFF</item> 
</style> 

Und in meiner Aktivität Layout verwende ich Spinner als:

<Spinner 
     android:id="@+id/spinner" 
     style="@style/spinner_style" /> 

Aber ich bekomme nicht das erforderliche Design. Hier ist das Layoutbild für den angegebenen Code. Der Spinner deckt den gesamten Bildschirm statt Höhe wie wrap_ Inhalt:

layout image

+0

@ samadhan-medge Bitte helfen Sie mir, wenn Sie können, da ich die Lösung aus einer Ihrer Antworten folgte. Vielleicht kannst du mir helfen. :) –

Antwort

0

Ich brauche Veränderung

<item name="android:layout_height">wrap_content</item> 

zu

<item name="android:layout_height">30dp</item> 

in style.xml hinzuzufügen. Obwohl ich immer noch nicht weiß, warum Wrap-Inhalt hier nicht funktioniert.