1

I am trying to implement a SearchView and a menu option (as icon) on the toolbar.

Here is the menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:salesi="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/search_filter_view"
        salesi:showAsAction="always"
        salesi:actionLayout="@layout/layout_search_menu_bar"
    android:title="" />

</menu> 

Used action layout feature to feed a separate layout xml shown below.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

<android.support.v7.widget.SearchView
    android:id="@+id/search_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/save_icon"
    android:iconifiedByDefault="false"
    android:searchIcon="@android:drawable/ic_menu_search"
    app:iconifiedByDefault="true" />


<android.support.v7.widget.AppCompatImageView
    android:id="@+id/save_icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerInParent="true"
    android:layout_centerVertical="false"
    android:layout_marginRight="10dp"
    app:srcCompat="@drawable/ic_save_me" />
</RelativeLayout>

The menu is inflated correctly with SearchView and save icon. However, there is line strip just before the SearchView. Not sure what is causing it to happen. Looks like the search icon is hidden. Margins and padding did not work.

enter image description here

Any thoughts on this? Any clue I can give a try.

Renjith
  • 3,457
  • 5
  • 46
  • 67

0 Answers0