如何将自定义对话框显示为容器的中心?
How to display custom dialog as a center of the container?
Dialog customdialog = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar); Window window = customdialog.getWindow(); window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); window.setGravity(Gravity.CENTER);R.style.Theme_Translucent_NoTitleBar - 用于删除 cutomdialog 的边框.一旦我使用了这条线,对话框就会出现在平板电脑的左上角?
R.style.Theme_Translucent_NoTitleBar - is used to remove border for cutomdialog. Once i used this line the dialog will appear at the topleft corner of the tablet?
谁能帮我解决这个问题?
Can anyone help me to solve this issue?
推荐答案把fill_parent改成wrap_content.希望这是activity一角出现对话框的问题,占用了整个布局的空间.所以改了这可能会帮助您获得真正想要的东西.
Change the fill_parent to wrap_content.I hope this will be the issue the dialog appear at the corner of the activity.It takes the space of whole layout.So changing this may help you to get what you realy wanted.
Window window = customdialog.getWindow(); window.setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.CENTER);在 dialog.show() 语句后使用上面的代码
Use above code after dialog.show() statement
更多推荐
Android:在容器中心显示自定义对话框
发布评论