0

I have this AlertDialogwith and dynamic list in it(when a item from the list is selected the content of the list changes also). 问题是初始对话框的高度与其父级匹配,但是当内容更改并且大小小得多时,对话框会包裹内容。我怎样才能避免这种情况?

public ExplorerDialog(Context context, final SettingsDialog settingsDialog, int fileType) {  
    super(context); 

    setIcon(R.drawable.dialog_explorer_file_manager); 
    setTitle("Explorer Dialog"); 
    setView(LayoutInflater.from(context).inflate(R.layout.dialog_explorer_layout, null)); 
    setButton(BUTTON_POSITIVE, "Done", new OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
            settingsDialog.show(); 
        } 
    }); 

    setButton(BUTTON_NEGATIVE, "Cancel", new OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
            settingsDialog.show(); 
        }
    });
}
4

2 回答 2

1

您可能已将警报对话框的视图设置为列表,这是获得所需内容的快速方法:

 d.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, 600)

其中 d 是创建的对话框,这允许您设置宽度和高度的值。

于 2012-12-05T04:21:38.157 回答
0

您的 cusyom 对话框布局:

LinearLayout dialoglayout = (LinearLayout) dialog.findViewById(R.id.dialoglayout);

dialoglayout.setLayoutParams(new FrameLayout.LayoutParams(700,1100));

或者

如果你想要屏幕尺寸的宽度:

dialoglayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,1100));
于 2012-12-05T13:39:56.293 回答