Search View

Features


Min SDK : 14
Price : Free
Language : Java

 

Download


Link : Github
Owner : lapism
Source Code : Download

 

Usage

Add the dependencies to your gradle file:

dependencies {
implementation 'com.lapism:searchview:5.0.0-alpha3'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

Screenshot 1
Screenshot 2

Code:

// For SearchView.Version.MENU_ITEM and SearchView.Version.TOOLBAR
SearchView mSearchView = (SearchView) findViewById(R.id.searchView);
// Only for SearchView.Version.MENU_ITEM
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_search: {
mSearchView.open(true/false); // enable or disable animation
return true;
}
default:
return super.onOptionsItemSelected(item);
}
}

XML:

<com.lapism.searchview.SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

XML with CoordinatorLayout:

<com.lapism.searchview.SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="match_parent" 
app:layout_behavior="com.lapism.searchview.SearchBehavior" />

Versions:

SearchView identifies its layout style through versions. Currently, there are two values, namely SearchView.Version.TOOLBAR for the persistent view, and SearchView.Version.MENU_ITEM for the view that appears on a menuitem press. The version may be defined through setVersion.

Styling SearchView:

<attr name="search_version" format="enum">
<enum name="toolbar" value="1000" />
<enum name="menu_item" value="1001" />
</attr>
<attr name="search_version_margins" format="enum">
<enum name="toolbar_small" value="2000" />
<enum name="toolbar_big" value="2001" />
<enum name="menu_item" value="2002" />
</attr>
<attr name="search_theme" format="enum">
<enum name="light" value="3000" />
<enum name="dark" value="3001" />
<enum name="play_store" value="3002" />
</attr>
<attr name="search_height" format="dimension" />
<attr name="search_navigation_icon" format="integer" />
<attr name="search_icon_color" format="color" />
<attr name="search_background_color" format="color" />
<attr name="search_text_color" format="color" />
<attr name="search_text_highlight_color" format="color" />
<attr name="search_text_size" format="dimension" />
<attr name="search_text_style" format="enum">
<enum name="normal" value="0" />
<enum name="bold" value="1" />
<enum name="italic" value="2" />
<enum name="bold_italic" value="3" />
</attr>
<attr name="search_hint" format="string" />
<attr name="search_hint_color" format="color" />
<attr name="search_voice" format="boolean" />
<attr name="search_voice_text" format="string" />
<attr name="search_animation_duration" format="integer" />
<attr name="search_shadow" format="boolean" />
<attr name="search_shadow_color" format="boolean" />
<attr name="search_elevation" format="dimension" />
<attr name="search_clear_on_open" format="boolean" />
<attr name="search_clear_on_close" format="boolean" />
<attr name="search_hide_on_keyboard_close" format="boolean" />
<attr name="search_cursor_drawable" format="integer" />