Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Bit annoying that I've just done it, but here is a method of doing it using the built-in Spinner in the action bar. All you need to do is make your spinner item's main container a <code>RelativeLayout</code> and set its gravity to fillHorizontal, like so:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="fill_horizontal" android:orientation="vertical" &gt; &lt;TextView android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginBottom="-4dip" android:text="@string/gen_placeholder" android:textAppearance="?android:attr/textAppearanceMedium" /&gt; &lt;TextView android:id="@+id/TextView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@android:id/text1" android:text="@string/app_name" android:textAppearance="?android:attr/textAppearanceSmall" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And initialising the Adapter as so:</p> <pre><code>ArrayAdapter&lt;CharSequence&gt; barAdapter = new ArrayAdapter&lt;CharSequence&gt;(this, R.layout.subtitled_spinner_item, android.R.id.text1, getResources().getStringArray(R.array.actionList)); barAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); </code></pre> <p>which then gives the required spinner spanning the entire actionbar (except for the action buttons): </p> <p><img src="https://i.stack.imgur.com/8RBGW.png" alt="Spanned actionbar"></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