1、PopupDownMenu介绍
想必大家在各种诸如美团,淘宝等app上都有看到过这样的下拉菜单筛选栏,而据我所知,别人还原的做法大多是用单纯的ListView或者ExpandableListView更或者自定义View之类的来实现,但我是第一想法使用利用PopupWindow+ListView的方法实现的,所以就有了这个项目。
同样,为了提高这个的利用性,我为PopupWindow设置了一个包装类,判断不同级别的目录有不同的做法,因为一般的app也只会做到三级目录,我在操作上就只做到三级的效果了。但是有了这个包装类,实现起来将会十分简单~只需要按规则放入数据就可以了。(因为是实现效果了就放出来了,就求不要吐槽界面丑了)
2、直接看预览图
3、使用方法
3.1Gradle
在project 中build.gradle下增加:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
在app中build.gradle下添加:
dependencies {
implementation 'com.github.ChitoseYono:PopupDownMenu:v1.0.2'
}
3.2布局文件
以单单一个三级菜单为例,需要一个有三个ListView的布局文件:
<?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"
android:orientation="horizontal"
android:baselineAligned="false"
>
<ListView
android:id="@+id/pop_listview_left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:dividerHeight="0.5dp"
android:divider="#e2e2e2"
android:scrollbars="none"
android:scrollingCache="false"
/>
<ListView
android:id="@+id/pop_listview_center"
android:layout_width="match_parent"
android:layout_height="wra