Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make the spinner width same as largest available item width
    primarykey
    data
    text
    <p>I realize even I use <code>wrap_content</code> for my spinner (I avoid using <code>match_parent</code> as I do not want the spinner overly long), and using <code>match_parent</code> for spinner's item view and drop down item view, </p> <p>I still find the spinner's width is not same as largest item's width</p> <p><img src="https://i.stack.imgur.com/wM0Yx.png" alt="enter image description here"></p> <p>As you can see, the <code>UnitedKingdom</code> is not fit.</p> <p>So, if I select the <code>UnitedKingdom</code>, only the spinner's will resize</p> <p><img src="https://i.stack.imgur.com/ozbeH.png" alt="enter image description here"></p> <p>How can I make the spinner resize to the largest available item width, even without being explicitly selecting the largest item?</p> <p>My spinner XML is</p> <pre><code>&lt;Spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" /&gt; </code></pre> <p>and my spinner's views XML are</p> <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text_view_0" style="?android:attr/spinnerItemStyle" android:singleLine="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawablePadding="10dp" android:gravity="center_vertical" /&gt; </code></pre> <hr> <pre><code>&lt;CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/checked_text_view_0" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="true" android:layout_width="match_parent" android:layout_height="48dp" android:minHeight="48dp" android:drawablePadding="10dp" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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