Android:在容器中心显示自定义对话框

编程入门 行业动态 更新时间:2024-10-28 10:37:07
本文介绍了Android:在容器中心显示自定义对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将自定义对话框显示为容器的中心?

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:在容器中心显示自定义对话框

本文发布于:2023-08-02 17:12:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279622.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   对话框   容器   中心   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!