Can I make Dialog without a title on Android?

Asked 2 years ago, Updated 2 years ago, 118 views

On Android

dialog = new Dialog(this);
dialog.setContentView(R.layout.my_dialog);

I'm going to make a custom dialog like this. It works well except for the title being printed out. Even if you take out the title, if the dialog pops up, that part comes out blank, so it's a problem.

Is there any way to hide the title part of the dialog?

LayoutInflater inflater = 
    (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.map_dialog, null);

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);

// // dialog = new Dialog(this);
// // dialog.setContentView(R.layout.map_dialog);

dialog = builder.create();

((TextView) dialog.findViewById(R.id.nr)).setText(number);

I tried it like this, but I don't know what's the attribute of hiding the title.

android android-layout dialog

2022-09-22 16:43

1 Answers

If you want to hide the title of the dialog, dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); You can add this code.


2022-09-22 16:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.