Skip to content Skip to sidebar Skip to footer

Android Custom Alert Dialog With Rounded Corners And Transparent Background

I have created a custom AlertDialog with rounded corners using onDraw of LinearLayout as below, public class RoundedLinearLayout extends LinearLayout { private Paint drawPaint; pr

Solution 1:

I use this and it worked for me:

ConfirmacionMensajecustomDialog=newConfirmacionMensaje(MainActivity.this);
customDialog.getWindow().setBackgroundDrawable(newColorDrawable(android.graphics.Color.TRANSPARENT));
customDialog.show();

ConfirmacionMensaje exntends from Dialog

and this is my xml for Dialog:

<?xml version="1.0" encoding="UTF-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"
><solidandroid:color="#ffDB0000"/><cornersandroid:bottomLeftRadius="4dp"android:bottomRightRadius="4dp"android:topLeftRadius="4dp"android:topRightRadius="4dp" /></shape>

Solution 2:

Do use alert dialog use simple dialog

LayoutInflaterfactory= LayoutInflater.from(getActivity());
            AlertDialogalert=newAlertDialog.Builder(getActivity());

        Dialogdialog=newDialog(getActivity());

            dialog.setContentView(your layout);

            dialog.getWindow().setBackgroundDrawable(
                    newColorDrawable(android.graphics.Color.TRANSPARENT));

Solution 3:

Use this :

dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

It is the simplest solution and it works.

Solution 4:

This worked for me

dialog.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.background_verification));

background verification is my drawable file

Solution 5:

This can be solved:

   dialog.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.background_verification));

Post a Comment for "Android Custom Alert Dialog With Rounded Corners And Transparent Background"