简体   繁体   English

如何创建全屏 MaterialAlertDialog

[英]How to create full screen MaterialAlertDialog

I am trying to show a full screen alert dialog like the one on the material design website: Full Screen Material Alert Dialog我正在尝试显示一个全屏警报对话框,就像材料设计网站上的那样: 全屏材料警报对话框

I created a我创建了一个

new MaterialAlertDialogBuilder(this)
   .setTitle("Title")
   .setMessage("Message")
   .setPositiveButton("Yes", null)
   .show();

which works perfectly.效果很好。 However I want the dialog to appear as full screen with the toolbar and x button, so I can place EditText s inside the dialog.但是我希望对话框显示为带有工具栏和 x 按钮的全屏,因此我可以将EditText放置在对话框中。

I tried using the other constructor MaterialAlertDialogBuilder(context, theme) but I cannot find a theme that will make the dialog appearance full screen.我尝试使用其他构造函数MaterialAlertDialogBuilder(context, theme)但我找不到可以使对话框全屏显示的主题。 Is there a theme that makes the dialog full screen or do I have to do something else to make it full screen?是否有使对话框全屏显示的主题,或者我是否必须执行其他操作才能使其全屏显示?

try this尝试这个

MaterialAlertDialogBuilder dialog = new MaterialAlertDialogBuilder(this, android.R.style.Theme_DeviceDefault_NoActionBar_Fullscreen);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM