Android 如何更改程序中的AlertDialog大小?
我有一个Android 如何更改程序中的AlertDialog大小?,android,android-alertdialog,Android,Android Alertdialog,我有一个警报对话框,我想调整它的大小以适应文本的长度和高度。我的工作如下: AlertDialog dialog = new AlertDialog.Builder(thisActivity); dialog.setMessage(curitem.getTitle()); dialog.show(); TextView textView = (TextView) dialog.findVie
警报对话框
,我想调整它的大小以适应文本的长度和高度。我的工作如下:
AlertDialog dialog = new AlertDialog.Builder(thisActivity);
dialog.setMessage(curitem.getTitle());
dialog.show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(7);
textView.setGravity(1);
我可以更改文本大小和字体。但我无法调整
对话框的大小。如何使对话框大小刚好适合文本长度和高度?此代码可能会对您有所帮助。在此代码中,您必须进行一些修改(根据需要提供高度和宽度)
你可以试试
dialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
或者您想要的任何其他整数值。是,它可以工作。我将(宽度、高度)放在整数值中。
dialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);