How to implement SearchView with Toolbar in Android? -


i trying implement toolbar have done in android studio, cannot figure out how add searchview once search icon clicked.

the toolbar without search opened

this want toolbar when search icon clicked.

the toolbar search opened

this toolbar.xml file:

<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:background="#000000"     android:elevation="5dp"     android:contentinsetleft="15dp"     >      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="bean"         android:layout_gravity="center"         android:textcolor="@color/beanblue"         android:id="@+id/toolbar_title"         android:textsize="25sp"/>      <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/cart_icon"         android:id="@+id/cart_button"         android:layout_gravity="right"         android:layout_marginright="15dp"/>      <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/search_icon"         android:id="@+id/search_button"         android:layout_gravity="right"         android:layout_marginright="15dp"/>  </android.support.v7.widget.toolbar> 

how implement toolbar searchview included? implementing toolbar wrong?

try library. can solve problem

https://github.com/leonardoxh/fakesearchview


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -