Custom Dialog without title and border

Based on the code here, . I am successfully able to create a custom dialog with background and buttons inside, but there’s still something not right. there still a space for title bar, and there are border around the view. how to get rid of these title and border?

here is my dialog

  • Android onConfigurationChanged: how to save and restore fragment back stack?
  • Storage limit in raw and asset folder in android
  • Kotlin Android Extensions and Fragments
  • Create a Bitmap/Drawable from file path
  • Android Studio - Gradle sync project failed
  • Play Google (Android store) Statistics
  • Dialog pauseMenu = new Dialog(this,R.xml.pause_dialog);
    return pauseMenu;

    and here is my pause layout

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="" android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:background="@drawable/pause_menu_cropped" android:layout_gravity="center" android:gravity="center|center_horizontal">
        <TableLayout android:layout_width="wrap_content" android:id="@+id/tableLayout1" android:layout_height="wrap_content">
            <ImageButton android:src="@drawable/pause_button_quit" android:layout_width="wrap_content" android:background="@drawable/pause_button_quit" android:id="@+id/imageButton2" android:layout_height="wrap_content"></ImageButton>
            <ImageButton android:src="@drawable/pause_button_option" android:layout_width="wrap_content" android:background="@drawable/pause_button_option" android:id="@+id/imageButton1" android:layout_height="wrap_content"></ImageButton>

    Related posts:

    Android WebView with an embedded youtube video, full screen button freezes video
    WebView Crash by close failed: EIO (I/O error)
    New Relic Class Not Found &hellip; I don&#039;t even use new relic
    Bluetooth LE ScanFilters don&#039;t work on Android M
    The best way to caching json
    Android: Adding a fragment to an activity
  • Android Gallery with pinch zoom
  • How to make soap post request using Volley library in Android
  • Android Dialog theme makes icon too light
  • Android add border to edit text programmatically
  • AppCompatSpinner's entries not opening TimePickerDialog on selecting it second time. Please see details
  • How to reset Google Advertising ID in Android Programatically?
  • 9 Solutions collect form web for “Custom Dialog without title and border”

    A Dialog cannot be created without a title. Further down in that tutorial it mentions:

    A dialog made with the base Dialog
    class must have a title. If you don’t
    call setTitle(), then the space used
    for the title remains empty, but still
    visible. If you don’t want a title at
    all, then you should create your
    custom dialog using the AlertDialog
    class. However, because an AlertDialog
    is created easiest with the
    AlertDialog.Builder class, you do not
    have access to the setContentView(int)
    method used above. Instead, you must
    use setView(View). This method accepts
    a View object, so you need to inflate
    the layout’s root View object from

    This answer solves both the title and the border problem using a custom style.

    I think this will help you out

    gameOver would be the dialog name and in setContentView it would be ur custom dialog layout

    gameOver = new Dialog(Main.this);
    gameOver.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    1. Make a class like this:

      public class CustomDialog extends Dialog {
          public AlertFinishiView(Context context) {
              getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    2. make a xml in layut folder with this name dialog

      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="" 
            android:background="@drawable/bg_custom_dialog" >
            <Button android:id="@+id/button1" 
               android:text="Button" />
    3. add the image above in your drawable folder with name bg_custom_dialog.9.png


    1. call in your activity:

      CustomDialog customDialog = new CustomDialog(this);;
    Dialog dialog = new Dialog(Main.this);
    Dialog dialog = new Dialog(context);

    Try the following style in your styles.xml:

    <style name="free_floating_dialog" parent="@android:style/Theme.Holo.Light.Dialog">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowCloseOnTouchOutside">false</item>

    For more options see “Theme.Holo.Light.Dialog” which is part of the Android sources (since Honeycomb), or any other dialog style you based your’s on.

    Then simply use this style as basis to your own dialog:

    Dialog myDialog = new Dialog(getActivity(),;

    Use this, It works perfectly;

                 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before     

    How to create a completely custom Dialogue/Popup in Android (change overlay colour and dialogue window layout)

    this would give you as possible ways as that would help to improve this problem

    I use this code and it work fine:

    AlertDialog.Builder builder = new AlertDialog.Builder(contextActivity,;
    AlertDialog alertDialog = builder.create();
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.