Немного раздражает, что я только что сделал это, но вот способ сделать это, используя встроенный Spinner в панели действий. Все, что вам нужно сделать, это сделать основной контейнер вашего блесны элементом RelativeLayout
и установить его гравитацию для fillHor Horizontal, например:
<?xml version="1.0" encoding="utf-8"?>
<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" >
<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" />
<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" />
</RelativeLayout>
И инициализация Адаптера следующим образом:
ArrayAdapter<CharSequence> barAdapter = new ArrayAdapter<CharSequence>(this, R.layout.subtitled_spinner_item,
android.R.id.text1, getResources().getStringArray(R.array.actionList));
barAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
, который затем дает требуемый счетчик, охватывающий всю панель действий (кроме кнопок действий):