之前做过一些需求,因为开发周期短,在产品分类的弹窗上一直有一些遗憾,这次又遇到了分类的页面要做,所以花了点时间思考,利用一个开源组件SlideBottomPanel成功实现了一个体验很好的分类功能
网上流传了很多版本的弹窗,但基本都是基于popWindow,Spinner,或者直接覆盖一层Dialog,大多用户必须手点把外层的弹窗点掉,才能选择其他种类的分类放,逼死强迫
症有木有。
捣鼓了一番,效果如下
真正使用效果会非常平滑
废话不多说,Git地址https://github.com/kingideayou/SlideBottomPanel
下载后可以直接把几个java文件复制到自己的项目中,同时记得复制attr参数信息
项目需要Jar包:SmartAndroid
全部弄好,写页面~
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#fff"
android:orientation="vertical">
<include layout="@layout/search_tit"></include>
<com.xuleyuan.sortmenu.view.slidebottompanel.SlideBottomPanel
android:id="@+id/sbp"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:sbp_panel_height="200dp"
app:sbp_background_layout="@layout/background_layout"
app:sbp_title_height_no_display="0dp"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#ffffff"
android:orientation="vertical">
<ListView
android:id="@+id/lv_credit_sort"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
</com.xuleyuan.sortmenu.view.slidebottompanel.SlideBottomPanel>
</LinearLayout>
SlideBottomPanel中的一个属性background_layout必须填,这里定义的这个控件所覆盖的页面,可以理解成它本身是一个Framelayout,这个属性定义的是最底层的一个页面
,如果你用其他手段(外部用FrameLayout去做重叠,那么他会强制截取掉你的触摸事件)
我这边简单的做了一个空的页面background_layout,内部是可以任意编辑的,比如在其中加入ScrollView等
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
下面是search_tit页面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal"
android:grav