I am having a List Activity which include a SearchView and ListView. I wish to have SearchView similar to what is present in google maps android app.
Currently my SearchView code in activity_main.xml is
<SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:queryHint="Search restaurants"
android:iconifiedByDefault="false"
android:id="@+id/searchView" />
Can someone guide me how to get a custom SearchView like above.
You can add a android.support.v7.widget.Toolbar
from AppCompat Library in your layout. It acts like a custom ActionBar that can be placed anywhere. Then you can add a menu toggle, and a android.support.v7.widget.SearchView
which can collapse/expand. finally, add some actions from a menu.xml
.
Setting a custom Toolbar as your ActionBar replacement:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.blah);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With