popupwindow怎么使用?
wealive opened this issue · 2 comments
wealive commented
popupwindow怎么使用?
DylanCaiCoding commented
目前没有对 PopupWindow 进行封装,可以考虑封装一下。你先用回 ViewBinding 原本的用法:
val popupItemBinding = PopupItemBinding.inflate(layoutInflater)
val popupWindow = PopupWindow(
popupItemBinding.root,
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
DylanCaiCoding commented
在最新的 2.0.0 版本增加了快速创建 PopupWindow 的方法,默认的宽高是 WRAP_CONTENT,可以传参修改宽高为 MATCH_PARENT 或者自定义大小。
private val popupWindow by popupWindow<LayoutPopupBinding> {
// private val popupWindow by popupWindow(LayoutPopupBinding::inflate) {
btnLike.setOnClickListener {
// ...
}
}