Sushant Bhatnagar
Sushant Bhatnagar

Reputation: 3784

How to display title of dialog in multi line?

Suppose I have a dialog which is opened from java file . I want to set multiline title of these dialog box.

  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);   

But it does not display title in multiline , please suggest me any usable link or example.

Upvotes: 4

Views: 4858

Answers (2)

Vishal Pawar
Vishal Pawar

Reputation: 4340

Add

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

immediately after calling super.onCreate and just before setContentView.

Then add the multiline textview on top of your dialog layout which will work as title

Upvotes: 3

user3581306
user3581306

Reputation: 101

TextView tv = (TextView) dialog.findViewById(android.R.id.title);
tv.setSingleLine(false);

Upvotes: 10

Related Questions