Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>This is a good article :</strong> <a href="http://android-developers.blogspot.com/2011/04/customizing-action-bar.html" rel="noreferrer">Customizing the Action Bar</a></p> <p>And also you can try this :</p> <p>Design you own customized drawable for spinner background and apply to it. For spinnerbackground.xml images you can refer the images from the SDK. recreate the images as per your design requirements </p> <blockquote> <p>"Android-sdk\platforms\android-9\data\res\drawable-hdpi\*.png"</p> </blockquote> <p>spinnerbackground.xml</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/wlbtn_dropdown_normal" /&gt; &lt;item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/wlbtn_dropdown_disabled" /&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/wlbtn_dropdown_pressed" /&gt; &lt;item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/wlbtn_dropdown_selected" /&gt; &lt;item android:state_enabled="true" android:drawable="@drawable/wlbtn_dropdown_normal" /&gt; &lt;item android:state_focused="true" android:drawable="@drawable/wlbtn_dropdown_disabled_focused" /&gt; &lt;item android:drawable="@drawable/wlbtn_dropdown_disabled" /&gt; &lt;/selector&gt; </code></pre> <p>then for spinner widget apply your custom drawable:</p> <pre><code>&lt;Spinner android:background="@drawable/spinnerbackground" android:id="@+id/spinnerIDr" android:layout_height="wrap_content" android:layout_width="fill_parent"&gt; &lt;/Spinner&gt; </code></pre> <p><strong>Edited :</strong> </p> <pre><code>&lt;Spinner android:background="@drawable/spinnerbackground" android:id="@+id/spinnerIDr" android:popupBackground="@drawable/popup_background" android:layout_height="wrap_content" android:layout_width="fill_parent"&gt; &lt;/Spinner&gt; </code></pre> <p>where popup_background is : <img src="https://i.stack.imgur.com/EhSyz.png" alt="enter image description here"></p> <p>and </p> <p>Design your custom layout for spinner texts as (name : custom_spiner.xml)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="4dp" android:textSize="14sp" android:typeface="serif" android:singleLine="true" android:layout_marginLeft="2dip" android:layout_marginRight="5dip" android:ellipsize="marquee" android:textColor="#000000"&gt; &lt;/TextView&gt; </code></pre> <p>and use it as </p> <pre><code>adapter.setDropDownViewResource(R.layout.custom_spiner); </code></pre> <p>in your code.</p> <p>Edited 2: </p> <p>if you want to do this using java code read about <a href="http://developer.android.com/reference/android/widget/PopupWindow.html" rel="noreferrer">PopupWindow</a></p> <p>And may be useful : <a href="http://android-er.blogspot.com/2010/12/custom-spinner-with-icon.html" rel="noreferrer">custom-spinner</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload