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

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

formula - R: how to pass in a reference to the variable in glm or lm? -