I'm creating an Android Action Bar using menu directory. While I was creating a new bar, I wanted to customize this action bar, so I added action-layout in one of items in xml file under menu directory. here is what I did
menu_main.xml(under menu directory)
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:orderInCategory="101"
android:id="@+id/menu_refresh"
android:title="refresh"
android:icon="@drawable/menu_refresh"
app:showAsAction="always"/>
<item
android:orderInCategory="102"
android:id="@+id/menu_search"
android:title="search"
app:showAsAction="always"
android:actionLayout="@layout/search_layout"/>
<item
android:orderInCategory="103"
android:id="@+id/menu_setting"
android:title="setting"
android:icon="@drawable/menu_settings"
app:showAsAction="always"/>
</menu>
in second item, i added actionLayout and search_layout.xml is just simeple LinearLayout with TextView and EditText.
search_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search"
android:textSize="16dp"
android:textColor="#ffad8745"/>
<EditText
android:id="@+id/editText"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:background="#ffad8745"/>
</LinearLayout>
My expectation was that the first and third item show icons whereas second item shows me a layout that I defined, but here's what i got: only the title that I defined in menu_main.xml.
I eventually made an action bar that I wanted, but I still don`t quiet understand why the way initially tried does't work. please help me out. thank you