今天的文章水一把
抽一个方法设置窗口的属性
fun setWindowConstraints(
context: Context,
window: Window,
view: DialogLayout,
maxWidth: Int?
) {
if (maxWidth == 0) {
// Postpone
return
}
window.setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
val lp = LayoutParams()
.apply {
copyFrom(window.attributes)
width = LayoutParams.MATCH_PARENT
height = LayoutParams.MATCH_PARENT
}
window.attributes = lp
}
然后,重写对话框的show方法
override fun show() {
setWindowConstraints()
super.show()
}