如何在 Kotlin 中更改 AlertDialog 的宽度和高度

How do I change the width and height of AlertDialog in Kotlin

如何在 Kotlin 中更改警报对话框的高度和宽度。我的警报对话框代码如下所示:

val loginProgressDialog = AlertDialog.Builder(this)
            .setView(layoutInflater.inflate(R.layout.alert_dialog, null))
            .setCancelable(false)
            .create()

我尝试了以下但没有用

    loginProgressDialog.window?.attributes?.width = 100
    loginProgressDialog.window?.attributes?.height = 100

如果你能 link 到 post 有解决方案的地方,我也很乐意。

你可以通过使用这个

来实现
loginProgressDialog.window?.setLayout(100, 100)

您应该仅在使用 loginProgressDialog.show()

显示 AlertDialog 后立即使用它