morristech
2/11/2019 - 7:56 PM

Android: Custom Styled Dialog without border or title

Android: Custom Styled Dialog without border or title

public void showCustomDialog() {
  Dialog dialog = new Dialog(this, R.style.Theme.CustomDialog);

  dialog.setContentView(R.layout.custom_dialog);
  // ...

  dialog.show();
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:drawableLeft="@drawable/ic_add"
    android:text="@string/my_button_label"/>

</LinearLayout>
  <style name="Theme.CustomDialog" parent="@android:style/Theme.Translucent.NoTitleBar">
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:padding">10dp</item>
    <item name="android:background">#ff90ff90</item>
  </style>