This is an Android L design search view. It support reveal animation, let's review.
2016.11.17 update
I develop another library about ripple animation, it's a ripple animation layout you can use if anywhere you want(it is above android 4.0). Later i will develop a file explore use Material Design, and i will add some useful function to the
LSearchViewlibrary.You can see theRippleEverywherehere https://github.com/onlynight/RippleEverywhere.
This is an Chinese local app, so you can't install it from google play.It just use for demo. If you want to try it, you can download here: http://www.wandoujia.com/apps/com.superlity.hiqianbei
This is the LSearchView demo, you can see the source code in this the demo module.
In your project root path build.gradle file, add this:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}And in your module path build.gradle file, add this:
dependencies {
compile 'com.github.onlynight:LSearchView:1.0.0'
}layout file:
<com.github.onlynight.library.lsearchview.LSearchView
android:id="@+id/searchView"android:layout_width="match_parent"android:layout_height="match_parent"android:padding="8dp"app:anim_origin_x="23dp"app:anim_origin_y="23dp"app:anim_time="500"app:back_btn_icon="@drawable/ic_back"app:search_bar_height="48dp"app:search_bg_color="#aa000000"app:search_btn_icon="@drawable/ic_search"app:search_hint="search something">
<ListViewandroid:id="@+id/listView"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="4dp"android:background="@drawable/l_search_view_bg"/>
</com.github.onlynight.library.lsearchview.LSearchView>controller java code:
searchView = (LSearchView) findViewById(R.id.searchView);
searchView.getSearchButton().setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewview) {
searchView.setSearching(true);
searchView.postDelayed(newRunnable() {
@Overridepublicvoidrun() {
searchView.setSearching(false);
}
}, 1000);
}
});
searchView.getBackButton().setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewview) {
onBackSearch();
}
});
privatevoidonBackSearch(){
searchView.hideWithAnim();
adapter.clear();
adapter.notifyDataSetChanged();
}<declare-styleablename="LSearchView">
<!-- search bar height; the default is 48dp;-->
<attrname="search_bar_height"format="dimension"/>
<!-- back button padding; back button size = search_bar_height - search_button_padding*2; the default is 12dp;-->
<attrname="back_button_padding"format="dimension"/>
<!-- search button padding; search button size = search_bar_height - search_button_padding*2; the default is 12dp;-->
<attrname="search_button_padding"format="dimension"/>
<!-- edit text view hint text; no default;-->
<attrname="search_hint"format="string"/>
<!-- search view background color; the default is 0xaa000000;-->
<attrname="search_bg_color"format="color"/>
<!-- search view animation duration time; no default value;-->
<attrname="anim_time"format="integer"/>
<!-- search view reveal animation start x from right; the default is 23dp;-->
<attrname="anim_origin_x"format="dimension"/>
<!-- search view reveal animation start y from top; the default is 23dp-->
<attrname="anim_origin_y"format="dimension"/>
<!-- search bar back button icon res; the default is R.darwable.ic_back;-->
<attrname="back_btn_icon"format="reference"/>
<!-- search bar search button icon res; the default is R.darwable.ic_search;-->
<attrname="search_btn_icon"format="reference"/>
</declare-styleable>/** * Set the searching state and change search button to progress bar. * If you mean to use it, first when you start search you should call * setSearching(true), and when you end your search you should call * setSearching(false). * @param searching is the searching state * @return */publicvoidsetSearching(booleansearching);
/** * You can get the back button use this method. * @return */publicLinearLayoutgetBackButton();
/** * You can get the search button use this method. * @return */publicLinearLayoutgetSearchButton();
/** * You can get the search edittext view use this method. * @return */publicEditTextgetSearchEdit();
/** * Call this method to show the view. * When initial the LSearchView it's invisible, * you must call this method to show it. */publicvoidshowWithAnim();
/** * Call this mehod to hide the view with animation. */publicvoidhideWithAnim();Copyright 2016 onlynight
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.

