可以伸缩的搜索栏,模仿 华为应用市场 。
-
在布局中加入
SearchBarView
:<com.yuqirong.searchbar.SearchBarView android:id="@+id/searchbarview" android:layout_width="match_parent" android:layout_height="40dp" android:layout_margin="8dp" app:search_bar_hint_text="@string/string_search_text" />
-
在代码中使用它,
startOpen()
为打开搜索栏;反之,startClose()
为关闭搜索栏:SearchBarView searchbarview = (SearchBarView) findViewById(R.id.searchbarview); searchbarview.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // enter search activity } }); searchbarview.startOpen(); // 打开搜索栏 ... searchbarview.startClose(); // 关闭搜索栏
属性名 | 格式 | 描述 |
---|---|---|
search_bar_color | color|reference | 搜索栏背景色 |
search_bar_position | enum | 搜索栏的位置(左或右) |
search_bar_status | enum | 搜索栏的状态(打开或关闭) |
search_bar_duration | integer | 搜索栏打开或关闭的动画时间 |
search_bar_hint_text | string|reference | 搜索栏的提示文本 |
search_bar_hint_text_color | color|reference | 提示文本的颜色 |
search_bar_hint_text_size | dimension|reference | 提示文本的字体大小 |
search_bar_icon | reference | 搜索栏的图标 |
- Email : [email protected]
- Weibo : @活得好像一条狗
Copyright (c) 2017 yuqirong
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.