如何修复AlertDialog不包装在所有设备上的布局

问题描述 投票:0回答:1

我尝试将alertDialog主题设置为R.style.Theme_MaterialComponents_Light_Dialog_Alert

虽然可以将我的alertDialog的内容包装到在华为y9(Android Pie)上膨胀的布局,但没有将其包装在lenovo api 19上]

我尝试将LayoutParams设置为wrap_content,但仍然无济于事:

val inflater = LayoutInflater.from(mCtx)
    val viewInflater = inflater.inflate(R.layout.popup_menu,null)
    val window = AlertDialog.Builder(mCtx,R.style.Theme_MaterialComponents_Light_Dialog_Alert)
            .setView(viewInflater)
            .setCancelable(false)
    alertD = window.create()
    //alertD.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT)
    alertD.show()

所以我需要我的AlertDialog将其内容包装到所有电话上的布局中。

<<

尝试创建自定义对话框样式并以百分比添加宽度和高度。

android android-layout android-theme
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.