theelfismike's answer pointed me in the right direction, but I was able to simplify it a bit. The answer he linked to referred to displaying a custom view with ActionBar#setCustomView
, whereas I'm trying to make an action view set with MenuItem#setActionView
take up the full width. It is possible that my simplification won't work well for ActionBar
custom views.
This is the xml that worked for me:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/visibility_search_edit_text"/>
</RelativeLayout>
Unfortunately, this hides the ActionBar
's title. An answer in the question theelfismike linked to referred to this problem, but I couldn't get the suggested workaround to work.
Also, RelativeLayout
seems to be the required root of an action view. I tried using a LinearLayout
with many different combinations of layout_gravity
and layout_width
, but I couldn't get a LinearLayout
to fill the full width.