Create Xml Layout
<ImageView android:id="@+id/logo" android:layout_width="match_parent" android:layout_height="100dp" android:src="@drawable/ic_cloud_done"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:background="@color/white"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/app_name" android:gravity="center_horizontal" android:textSize="18sp" android:padding="20dp" android:textColor="@color/black"/> </LinearLayout> <TextView android:id="@+id/dialog_ok" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Succesful" android:gravity="center_horizontal" android:textSize="18sp" android:textStyle="bold" android:padding="16dp" android:textColor="@color/white"/>
Java
/* Custom Dialog */ Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.custom_dialog); dialog.setCancelable(false); dialog.show(); TextView textView = dialog.findViewById(R.id.dialog_ok); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); Toast.makeText(MainActivity.this, "Working", Toast.LENGTH_SHORT).show(); } });