title: Custom spinner android
body: <blockquote>
    <p>Question: When setting adapter it hides its custom background</p>
  </blockquote>
  
  <p>I am trying to add custom background to spinner like this,</p>
  
  <pre><code> &lt;Spinner
              android:id="@+id/spinnerReferredBy"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:spinnerMode="dropdown"
              android:background="@drawable/custom_drop_down"/&gt;
  </code></pre>
  
  <blockquote>
    <p>my custom drawable is,</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;item&gt;
          &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt;
              &lt;solid android:color="#ffffff"/&gt;
              &lt;stroke
                  android:width="2dp"
                  android:color="#80000000"/&gt;
              &lt;padding
                  android:bottom="2dp"
                  android:left="2dp"
                  android:right="2dp"
                  android:top="2dp"/&gt;
  
          &lt;/shape&gt;
      &lt;/item&gt;
  
      &lt;item&gt;
          &lt;bitmap
              android:layout_width="50dp"
              android:layout_height="50dp"
              android:gravity="right|end"
              android:src="@drawable/ic_drop_down" /&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <blockquote>
    <p>Setting adapter like this</p>
  </blockquote>
  
  <pre><code> spinnerReferredBy.adapter = ArrayAdapter&lt;String&gt;(activity,R.layout.custom_spinner_item,referred)
  </code></pre>
  
  <blockquote>
    <p>Outputs</p>
  </blockquote>
  
  <ol>
  <li><p>without setting adapter
  <a href="https://i.stack.imgur.com/3Uapm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Uapm.png" alt="enter image description here"></a></p></li>
  <li><p>With adapter
  <a href="https://i.stack.imgur.com/SbAau.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SbAau.png" alt="enter image description here"></a></p></li>
  </ol>