![API](https://img.shields.io/badge/minSdk-21-brightgreen.svg?style=flat) ![API](https://img.shields.io/badge/targetSdk-33-brightgreen.svg?style=flat) [![Kotlin Version](https://img.shields.io/badge/Kotlin-blue.svg)](https://kotlinlang.org) [![Maven Central](https://img.shields.io/maven-central/v/io.github.lapism/search)](https://s01.oss.sonatype.org/content/repositories/releases/io/github/lapism/search) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ## DEPRECATED Please use: - com.google.android.material.search.SearchBar - com.google.android.material.search.SearchView # Search - Search component for Android - Material You Design - Styling - Kotlin ![Search](https://github.com/lapism/Search/blob/master/images/search.png) ## Api - Java = 1.8 - Kotlin = 1.8 Add the dependency to your gradle file: ```groovy repositories { google() mavenCentral() } dependencies { implementation 'io.github.lapism:search:2.0.1' } ``` ## Usage ```java binding.materialSearchView.requestFocus() binding.materialSearchView.clearFocus() ``` ### MaterialSearchBar ```java val toolbar = binding.materialSearchBar.getToolbar() setSupportActionBar(toolbar) binding.materialSearchBar.apply { navigationIconCompat = NavigationIconCompat.SEARCH setHint(getString(R.string.search)) setOnClickListener { binding.materialSearchView.requestFocus() } setNavigationOnClickListener { binding.materialSearchView.requestFocus() } } ``` ### MaterialSearchView ```java binding.materialSearchView.apply { addView(recyclerView) navigationIconCompat = NavigationIconCompat.ARROW setNavigationOnClickListener { binding.materialSearchView.clearFocus() } setHint(getString(R.string.search)) setOnQueryTextListener(object : MaterialSearchView.OnQueryTextListener { override fun onQueryTextChange(newText: CharSequence) { adapter.filter(newText) } override fun onQueryTextSubmit(query: CharSequence) { } }) setOnFocusChangeListener(object : MaterialSearchView.OnFocusChangeListener { override fun onFocusChange(hasFocus: Boolean) { } }) } ``` ### Layout You have to use app theme Theme.Material3.* or Theme.MaterialComponents.*. ```xml ``` ### XML attributes ```xml ``` ## Todo **Animation** - animation like Google, needs help :) ## Author * **Martin Lapiš** - [GitHub](https://github.com/lapism) ## License This project is licensed under the Apache License 2.0 - see the [LICENSE](https://github.com/lapism/Search/blob/searchview/LICENSE) file for details.