1.概述
PopupLayout是通用弹出布局辅助库,允许开发者从顶部、底部、左侧、右侧和中心这五个位置弹出自己指定的View,此外还提供圆角和动画特性。
2.效果预览
PS:本库的更多效果可以参考Github上的Gif演示(Github地址)
3.基本用法
Gradle配置
//根项目下的build.gradle
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
//主项目下的build.gradle
dependencies {
implementation 'com.github.CodingEnding:PopupLayout:v1.0'
}
基本使用
PopupLayout的使用非常简单,只需要执行以下两步:
1.初始化PopupLayout
通过调用静态方法init初始化PopupLayout。这个方法有两个参数:第一个参数是Context对象,第二个参数代表弹出布局的内容,可以将layout资源Id或者View对象作为参数传入,如下所示:
//1.使用layout资源Id作为弹出布局的内容
PopupLayout popupLayout=PopupLayout.init(MainActivity.this, R.layout.layout_left)