如何在多行显示对话框的标题?

Sus*_*gar 4 android android-widget android-layout

假设我有一个从java文件打开的对话框.我想设置这些对话框的多行标题.

  dialog = new Dialog(context);
  dialog.setContentView(R.layout.issue_attachment_preview);     
  String title=getString(R.string.previewImageDialogTitle)+"\n ["+attachment.filename+"]";
  dialog.setTitle(title);
  dialog.setCancelable(true);   
Run Code Online (Sandbox Code Playgroud)

但它不会在多行显示标题,请建议我任何可用的链接或示例.

小智 10

TextView tv = (TextView) dialog.findViewById(android.R.id.title);
tv.setSingleLine(false);
Run Code Online (Sandbox Code Playgroud)