今天我带来了一个非常实用的自定义搜索框,包括搜索框、热门搜索列表、最近常用的搜索列表等功能也差不多,可以直接重用,会大大节省你的开发时间有一点要负责任的告诉你,这个的实现是一个非常简单的自定义组合视图除了介绍之外,我还会和大家分享具体的实现过程。
一,实现效果
效果很常见,就是平常需求中的效果,上面是搜索框,下面是最近和热门搜索列表,为了方便大家在实际需求中使用,配置了很多属性,也进行了上下控件的拆分,也就是上边搜索框和下面的搜索列表的拆分,可以按需进行使用。
二、快速使用及属性介绍
快速使用
目前已经发布至远程Maven,大家可以进行远程依赖使用。
1、在你的根项目下的build.gradle文件下,引入maven。
allprojects {repositories {maven { url "/AbnerAndroid/almighty/raw/master" }}}
2、在你需要使用的Module中build.gradle文件下,引入依赖。
dependencies {implementation com.vip:search:1.0.0}
具体代码
1、xml中引入SearchLayout(搜索框)和SearchList(搜索列表),在实际开发中,根据需求可选择使用,二者是互不关联的。
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android="/apk/res/android"xmlns:app="/apk/res-auto"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingLeft="10dp"android:paddingRight="10dp"tools:context=".MainActivity"><com.vip.search.SearchLayoutandroid:id="@+id/search_layout"android:layout_width="match_parent"android:layout_height="40dp"android:layout_marginTop="10dp"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintTop_toTopOf="parent"app:search_bg="@drawable/shape_stroke_10" /><com.vip.search.SearchListandroid:id="@+id/search_list"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="10dp"app:is_hot_flex