Skip to content

Latest commit

 

History

History
executable file
·
167 lines (158 loc) · 6.87 KB

README_SearchView.md

File metadata and controls

executable file
·
167 lines (158 loc) · 6.87 KB

SearchView

Donations

Please support me!

Get it on Google Play

XML

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

XML for CoordinatorLayout

<com.lapism.searchview.widget.SearchView
    android:id="@+id/searchView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/search_behavior"
    <!-- or -->
    app:layout_behavior="com.lapism.searchview.widget.SearchBehavior" />

XML attributes

        <attr name="search_logo" format="enum">
            <enum name="google" value="1000" />
            <enum name="hamburger_arrow" value="1001" />
            <enum name="arrow" value="1002" />
        </attr>
        <attr name="search_shape" format="enum">
            <enum name="classic" value="2000" />
            <enum name="rounded" value="2001" />
            <enum name="oval" value="2002" />
        </attr>
        <attr name="search_theme" format="enum">
            <enum name="play" value="3000" />
            <enum name="google" value="3001" />
            <enum name="light" value="3002" />
            <enum name="dark" value="3003" />
        </attr>
        <attr name="search_version_margins" format="enum">
            <enum name="bar" value="5000" />
            <enum name="toolbar" value="5001" />
            <enum name="menu_item" value="5002" />
        </attr>
        <attr name="search_version" format="enum">
            <enum name="toolbar" value="4000" />
            <enum name="menu_item" value="4001" />
        </attr>
        <attr name="search_logo_icon" format="integer" />
        <attr name="search_logo_color" format="color" />
        <attr name="search_mic_icon" format="integer" />
        <attr name="search_mic_color" format="color" />
        <attr name="search_clear_icon" format="integer" />
        <attr name="search_clear_color" format="color" />
        <attr name="search_menu_icon" format="integer" />
        <attr name="search_menu_color" format="color" />
        <attr name="search_background_color" format="color" />
        <attr name="search_text_image" format="integer" />
        <attr name="search_text_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_animation_duration" format="integer" />
        <attr name="search_shadow" format="boolean" />
        <attr name="search_shadow_color" format="color" />
        <attr name="search_elevation" format="dimension" />

Java or Kotlin

SearchView searchView = findViewById(R.id.searchView);

Search.Version.MENU_ITEM:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_search:
            mSearchView.open();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

Public methods

Name Format Default Description
getLogo() ... ... ...
setLogo(@Search.Logo int logo) ... ... ...
getShape() ... ... ...
setShape(@Search.Shape int shape) ... ... ...
getTheme() ... ... ...
setTheme(@Search.Theme int theme) ... ... ...
setLogoIcon(@DrawableRes int resource) ... ... ...
setLogoIcon(@Nullable Drawable drawable) ... ... ...
setLogoColor(@ColorInt int color) ... ... ...
setMicIcon(@DrawableRes int resource) ... ... ...
setMicIcon(@Nullable Drawable drawable) ... ... ...
setMicColor(@ColorInt int color) ... ... ...
setMenuIcon(@DrawableRes int resource) ... ... ...
setMenuIcon(@Nullable Drawable drawable) ... ... ...
setMenuColor(@ColorInt int color) ... ... ...
setTextImeOptions(int imeOptions) ... ... ...
setTextInputType(int inputType) ... ... ...
getText() ... ... ...
setText(CharSequence text) ... ... ...
setText(@StringRes int text) ... ... ...
setTextColor(@ColorInt int color) ... ... ...
setTextSize(float size) ... ... ...
setTextStyle(int style) ... ... ...
setTextFont(Typeface font) ... ... ...
setTextGravity(int gravity) ... ... ...
setHint(CharSequence hint) ... ... ...
setHint(@StringRes int hint) ... ... ...
setHintColor(@ColorInt int color) ... ... ...
getQuery() ... ... ...
setQuery(CharSequence query, boolean submit) ... ... ...
setQuery(@StringRes int query, boolean submit) ... ... ...
getCustomHeight() ... ... ...
setCustomHeight(int height) ... ... ...
setElevation(float elevation) ... ... ...
setBackgroundColor(@ColorInt int color) ... ... ...
setAlpha(@FloatRange(from = 0.5, to = 1.0) float alpha) ... ... ...
isOpen() ... ... ...
setOnMicClickListener(Search.OnMicClickListener listener) ... ... ...
setOnMenuClickListener(Search.OnMenuClickListener listener) ... ... ...
setOnQueryTextListener(Search.OnQueryTextListener listener) ... ... ...
getVersion() ... ... ...
setVersion(@Search.Version int version) ... ... ...
getVersionMargins() ... ... ...
setVersionMargins(@Search.VersionMargins int versionMargins) ... ... ...
setDividerColor(@ColorInt int color) ... ... ...
setClearIcon(@DrawableRes int resource) ... ... ...
setClearIcon(@Nullable Drawable drawable) ... ... ...
setClearColor(@ColorInt int color) ... ... ...
setTextImage(@DrawableRes int resource) ... ... ...
setTextImage(@Nullable Drawable drawable) ... ... ...
setAnimationDuration(long animationDuration) ... ... ...
setShadow(boolean shadow) ... ... ...
setShadowColor(@ColorInt int color) ... ... ...
getAdapter() ... ... ...
setAdapter(RecyclerView.Adapter adapter) ... ... ...
addDivider(RecyclerView.ItemDecoration itemDecoration) ... ... ...
removeDivider(RecyclerView.ItemDecoration itemDecoration) ... ... ...
open(MenuItem menuItem) ... ... ...
animateLogoHamburgerToLogoArrow(boolean animate) ... ... ...
setLogoHamburgerOrLogoArrow(boolean set) ... ... ...
setOnLogoClickListener(Search.OnLogoClickListener listener) ... ... ...
setOnOpenCloseListener(Search.OnOpenCloseListener listener) ... ... ...