allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.ckfree:simplesearchbar:1.0'
}
<com.ckfree.common.SimpleSearchBar
android:id="@+id/mysearchbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
可定义如下自定义属性:
<com.ckfree.common.SimpleSearchBar
android:id="@+id/mysearchbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mCancelText="取消"
app:mCancelTextColor="#123456"
app:mCancelTextSize="14sp"
app:mHintColor="#123456"
app:mHintSize="13sp"
app:mHintText="这里是Hint内容"
app:mTextColor="#123456"
app:mTextSize="13sp" />
SimpleSearchBar mysearchbar = (SimpleSearchBar) findViewById(R.id.mysearchbar);
View displayview = ...//跟随searchbar显示隐藏的view
mysearchbar.init(displayview, new SimpleSearchBar.SearchBarWathcer() {
@Override
protected void _onTextChanged(String s) {
//实时获取文字变更
}
});