Is there a way to make the Title part of a Custom Dialog Box invisible?
Just a simple problem without any idea of how to do it. Does anyone know how/if this can be done?
Reason: I just want one solid dialog box with no partitions as it looks a little better in my application.
EDIT
public void showCustomDialog() {
开发者_运维知识库Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.customdialog);
TextView thisText = (TextView) dialog.findViewById(R.id.customDialogThisText);
thisText.setText("This");
TextView thatText = (TextView) dialog.findViewById(R.id.customDialogThatText);
thatText.setText("That");
ImageView image = (ImageView) dialog.findViewById(R.id.customDialogImageView);
image.setImageResource(R.drawable.icon);
//Crashes the program with an AndroidRuntimeError
//dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
dialog.show();
}
Just don't call setTitle() and there will be no title, like that:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
new AlertDialog.Builder(AlertDialogSamples.this)
.setView(textEntryView)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
})
.create();
Just call dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE); before setting the view of the dialog by dialog.setContentView(R.layout.customdialog);
精彩评论