仿美团、淘宝等三层以下的任意层级下拉筛选菜单PopupDownMenu

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
  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值