如何解决自定义对话框未在布局外显示图标
我制作了一个自定义对话框,但它不像我期望的那样工作,我一直在查看堆栈溢出中的其他答案,这是我的方法
val mDialogView =
LayoutInflater.from(mFragment.requireContext()).inflate(
R.layout.dialog_confirm,null
)
val mBuilder = AlertDialog.Builder(mFragment.requireContext(),R.style.CustomDialog).setView(mDialogView)
val mAlertDialog = mBuilder.show()
mAlertDialog.setCanceledOnTouchOutside(false)
mAlertDialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
val dialogBinding = DialogConfirmBinding.bind(mDialogView)
结果: volatile
我确实找到了适合我的答案,但我不知道要结合视图绑定
val dialog = Dialog(mFragment.requireContext())
dialog.setContentView(R.layout.dialog_confirm)
dialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
dialog.setCanceledOnTouchOutside(false)
dialog.show()
对我有用的结果: picture1
但即使我 setContentView(dialogbinding.root) 结果也会回到第一张图片。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。