Skip to content Skip to sidebar Skip to footer

How To Remove Title From Custom Dialog?

I implemented a layout in order to be my custom dialog layout like this:

Solution 1:

Create a new style, add:

<style name="NoTitleDialog" parent="@android:Theme.Dialog">
<item name="android:windowNoTitle">true</item> </style>

And finally :

Dialog d = new Dialog(this, R.style.nameOfStyle);

Edit: This answer


Solution 2:

try using DialogFragment class, it doesn't force title on custom views. you can make it a static nested class in your activity.

public static class MyDialogFragment extends DialogFragment {
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(R.layout.custom_view);
    return builder.create();
  }
}

make your Activity extend AppCompatActivity, use imports

import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;

then to show the dialog instantiate the dialog fragment call show() passing support fragment manager and a string tag as follows :

MyDialogFragment dialogFragment = new MyDialogFragment();
    dialogFragment.show(getSupportFragmentManager(), "f1");

Post a Comment for "How To Remove Title From Custom Dialog?"