Here is the action bar that I want to create.
Here is items that I put in menu.
<item
android:id="@+id/search"
android:title="Search"
android:showAsAction="ifRoom|collapseActionView"
android:actionLayout="@layout/search_layout"
/>
<item
android:id="@+id/search1"
android:title="PHOTO"
android:showAsAction="ifRoom"
android:actionLayout="@layout/search_layout"
/>
collapseActionView - collapses search menu on startup.
After click on search item it shows edit text like on picture 1. But I need always see it, not only after click.
If I set it to Always it will pop the menu items from the screen because of fill_parent.
<EditText
android:id="@+id/txt_search"
android:inputType="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
Is it possible to get width of title bar layout without menu items? In this case I can set fixed width to edittext item.
Is it any other approaches to make it work? In result it must be custom title layout + menu items. This custom layout must fill empty space between menu items and icon.
You can achieve this by setting a custom view in place of the action bar title.
The result is an
EditText
that fills the entire width of the action bar, except for the action buttons. It looks exactly like the first image in the question.Using Custom ActionBar, you can solve your Problem. For Custom ActionBar you have to create on Custom Layout as per following:
color.xml
styles.xml
now you need to create ViewGroup and ActionBar in your java file as per following: