MaterialSearchView
MaterialSearchView copied to clipboard
Issue while using MaterialSearchView inside a Fragment Activity
I am using a navigation drawer and I want to provide search functionality in one of my fragment. But, when I use MaterialSearchView inside fragment, everything works fine except for the layout part. The Search bar on expanding appears below the toolbar and has two back arrows to collapse it and both has to be pressed.
-
On launching the activity:
-
On clicking on Search icon:
-
On clicking back button on the left of the search box:
Below is the code of my fragment's xml file,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.mypackagename.FirstFragment">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar_container">
<ExpandableListView
android:id="@+id/elv_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<FrameLayout
android:id="@+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<com.miguelcatalan.materialsearchview.MaterialSearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
</RelativeLayout>