Skip to content Skip to sidebar Skip to footer

Android: Change Custom Alertdialog Background

dialog layout xml:

Solution 1:

I had the same problem, I managed to fix it using a custom dialog like this:

public class CustomDialog extends Dialog {
    public CustomDialog(Context context, View view) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(view);
        getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);
    }
}

Solution 2:

Hey setting your view to builder creates this gray lines on top-bottom,instead you can setView to your dialog.like dialog.setView(layout,0,0,0,0);It will bound your layout to whole dialog.

Solution 3:

Another option is to remove android:background="@android:color/white" from your layout. Then the alert dialog will have its default light grayish background uniformly. (Since you have forced an inverse on a dark theme) At least it would look nice and worth the hassle. Just my two cents.

Post a Comment for "Android: Change Custom Alertdialog Background"