Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/claudiodegio/MsvSearch

Material Search View
https://github.com/claudiodegio/MsvSearch

android library material material-search

Last synced: about 22 hours ago
JSON representation

Material Search View

Lists

README

        

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Material%20Search%20View-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/4765)

# Material Search View
Cute library to implement SearchView in a Material Design Approach. *Works from Android API 14 (ICS) and above*.


Get it on Google Play

![sample](https://raw.githubusercontent.com/claudiodegio/MsvSearch/master/screen/Resized-1.png)
![sample](https://raw.githubusercontent.com/claudiodegio/MsvSearch/master/screen/Resized-2.png)
![sample](https://raw.githubusercontent.com/claudiodegio/MsvSearch/master/screen/Resized-3.png)
![sample](https://raw.githubusercontent.com/claudiodegio/MsvSearch/master/screen/Resized-4.png)

# Usage
**Add the dependencies to your gradle file:**
```javascript
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.claudiodegio:MsvSearch:1.0.0'
}
```
**Add MaterialSearchView to your layout file along with the Toolbar** *(Add this block at the bottom of your layout, in order to display it over the rest of the view)*:

```xml


```

**Create a menu resource file and add the search item into the menu file:**
```xml



```
**Add define it in the *onCreateOptionsMenu*:**
```java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);

MenuItem item = menu.findItem(R.id.action_search);
searchView.setMenuItem(item);

return true;
}
```

**Implement following methods from OnSearchViewListener**
```java
@Override
public void onSearchViewShown() {

}

@Override
public void onSearchViewClosed() {

}

@Override
public boolean onQueryTextSubmit(String query) {
// handle text submit and then return true
return false;
}

@Override
public void onQueryTextChange(String newText) {

}
```
**Hook your OnSearchViewListener and don't forget to add toolbar and set it as support action bar!!**
```java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_msv_simple);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

mSearchView = (MaterialSearchView) findViewById(R.id.sv);
mSearchView.setOnSearchViewListener(this); // this class implements OnSearchViewListener
}
```

**More detailed and advanced examples coming soon!**

# Help me
Pull requests are more than welcome, help me and others improve this awesome library.

# License
Copyright 2016 Claudio Degioanni

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.