是否有一种方法,当显示一个对话框在Android告诉应用程序显示弹出?



我有一个全屏应用程序,有按钮,希望有一个自定义下拉,当他们被点击。我想有一个自定义对话框显示,将有选项。有没有办法告诉对话框在哪里出现?

如果你想创建一个对话框

//Dialog reference
Dialog dialog;
//Instantiate here your dialog
dialog = ... ;
//Get window layout parameters reference
Window window = dialog.getWindow();
WindowManager.LayoutParams windowLayoutParams = window.getAttributes();
//Set the parameters you want
windowLayoutParams.gravity = Gravity.CENTER; //e.g. dialog's will be centered
window.setAttributes(windowLayoutParams);

你可以用Gravity代替。底部或重力。TOP显示相应的对话框。或者,对于更具体的定位,您可以尝试设置属性"windowLayoutParams.x">&"windowLayoutParams.y">

最新更新