对应文章:封装一个通用的PopupWindow
一个通用的 PopupWindow 的封装,欢迎 star!
- 添加 jitpack 仓库地址:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- 添加依赖
dependencies {
implementation 'com.github.jzmanu:MPopupWindow:v1.0.0'
}
MPopupWindow.create(this)
.setLayoutId(R.layout.popup_window_layout)
.setBackgroundDrawable(ColorDrawable(Color.GREEN))
.setAnimationStyle(R.style.PopupWindowScaleTheme)
.setOnDismissListener {}
.setTarget(mTarget)
.setGravity(gravity)
.build()
.show()