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 1 month ago
JSON representation
Material Search View
- Host: GitHub
- URL: https://github.com/claudiodegio/MsvSearch
- Owner: claudiodegio
- Created: 2016-12-03T18:32:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-27T12:28:20.000Z (almost 7 years ago)
- Last Synced: 2024-08-02T01:22:39.391Z (4 months ago)
- Topics: android, library, material, material-search
- Language: Java
- Homepage:
- Size: 771 KB
- Stars: 144
- Watchers: 6
- Forks: 36
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - MsvSearch - Material Design风格搜索视图 (SearchView)
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*.![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 DegioanniLicensed 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 athttp://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.