MiguelCatalan / MaterialSearchView

Cute library to implement SearchView in a Material Design Approach
http://miguelcatalan.info/2015/09/23/MaterialSearchView/
Apache License 2.0
3.83k stars 616 forks source link

How to show material searchview in actionbar #197

Open Iamthemax opened 6 years ago

Iamthemax commented 6 years ago

I cant figure out the way to add searchview on actionbar as i want to have back to parent button & cart icon on actionbar with search view

1Kamal1 commented 6 years ago

You need to Use Custom Toolbar and then use SearchView with Toolbar for example in my case i have Navigation Drawer so I wants to add Seach Icon with it and then open SearchBar When User Click on Search Icon

So for that what i have Done is :

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

    <com.quinny898.library.persistentsearch.SearchBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:id="@+id/searchbox" />
    </FrameLayout>
</android.support.design.widget.AppBarLayout>

if you are also using Navigation Drawer then add this code in app_bar_main