title: Spinner's Drop Down not working properly
body: <p>I want to create <code>custom Spinner Dialog</code> for my app. I have found <a href="http://adanware.blogspot.in/2012/03/android-custom-spinner-with-custom.html" rel="nofollow noreferrer">this</a> &amp; <a href="http://hasmukhbhadani.blogspot.in/search/label/SpinnerView%20in%20android." rel="nofollow noreferrer">this</a>.
  both are good.I have update my code as per requirement. i am using selector file for changing dialog background view when user tap on spinner.</p>
  
  <p>My code is working perfectly but issue is in dialog view. its spreading that width but i want to get according to some fix size.</p>
  
  <p><strong>The current output of my Spinner View is as Follows:-</strong></p>
  
  <p><img src="https://i.stack.imgur.com/Gnnse.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/jPFX1.png" alt="enter image description here"></p>
  
  <p><strong>But i need it as Follows:-</strong></p>
  
  <p><img src="https://i.stack.imgur.com/GKIua.jpg" alt="enter image description here"></p>
  
  <p><strong>Spinner_item.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/spinner_popup" // it's my selector file
      android:orientation="horizontal" &gt;
  
      &lt;TextView
          android:id="@+id/Genere_name"
          android:layout_width="wrap_content"
          android:layout_height="30dp"
          android:layout_marginLeft="5dp"
          android:ellipsize="marquee"
          android:gravity="center_vertical"
          android:singleLine="true"
          android:textColor="@android:color/black"
          android:textSize="18sp"
          android:textStyle="bold" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>spinner_popup.xml</strong></p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item android:drawable="@drawable/popup_header" android:state_selected="true"/&gt;
      &lt;item android:drawable="@android:color/transparent" android:state_enabled="true"/&gt;
      &lt;item android:drawable="@drawable/popup_header" android:state_pressed="true"/&gt;
      &lt;item android:drawable="@drawable/popup_bg_box" android:state_enabled="false" android:state_focused="true"/&gt;
      &lt;item android:drawable="@android:color/transparent"/&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p><strong>Main_spinner_view</strong></p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/search_layout"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/search_bg"
      android:orientation="horizontal"
      android:weightSum="3" &gt;
  
      &lt;Spinner
          android:id="@+id/Search_Spinner"
          android:layout_width="95dp"
          android:layout_height="30dp"
          android:layout_gravity="left|center_vertical|center_horizontal"
          android:layout_marginLeft="2dp"
          android:layout_weight="1.2"
          android:background="@drawable/search_dropdown" /&gt;
  
      &lt;EditText
          android:id="@+id/Search_EDT"
          android:layout_width="170dp"
          android:layout_height="30dp"
          android:layout_gravity="center|center_horizontal|center_horizontal"
          android:layout_marginLeft="3dp"
          android:layout_weight="1.5"
          android:background="@drawable/search_textfield"
          android:hint="Search By Free Text"
          android:inputType="textPersonName"
          android:padding="5dp"
          android:textSize="16sp" &gt;
      &lt;/EditText&gt;
  
      &lt;Button
          android:id="@+id/Search_GO"
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:layout_gravity="right|center_horizontal|center_vertical"
          android:layout_marginLeft="2dp"
          android:layout_marginRight="2dp"
          android:layout_weight="0.3"
          android:background="@drawable/search_icon"
          android:textColor="@android:color/white" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Here i am calling my spinner adapter</strong></p>
  
  <pre><code>Search_Spinner.setAdapter(new MyAdapter(GridViewActivity.this,
                  R.layout.spinner_item, Search_Category_List));
  </code></pre>
  
  <p>I think java code is not necessary but still i am paste here,</p>
  
  <pre><code>public class MyAdapter extends ArrayAdapter&lt;String&gt;
      {
  
          public MyAdapter(Context context, int textViewResourceId,
                  ArrayList&lt;String&gt; objects)
          {
              super(context, textViewResourceId, objects);
          }
  
          @Override
          public View getDropDownView(int position, View convertView,
                  ViewGroup parent)
          {
  
              return getCustomView(position, convertView, parent);
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent)
          {
              return getCustomView(position, convertView, parent);
          }
  
          public View getCustomView(int position, View convertView,
                  ViewGroup parent)
          {
  
              LayoutInflater inflater = getLayoutInflater();
              View row = inflater.inflate(R.layout.spinner_item, parent, false);
              TextView label = (TextView) row.findViewById(R.id.Genere_name);
              spinner_text = Typeface.createFromAsset(getAssets(), "desc.ttf");
              label.setTypeface(spinner_text);
              label.setText(Search_Category_List.get(position));
  
              return row;
          }
      }
  </code></pre>