white background under alert dialog box

When initializing dialog builder, pass second parameter as the theme. So Change

AlertDialog.Builder builder = new AlertDialog.Builder(activity);

to

AlertDialog.Builder builder = new AlertDialog.Builder(activity, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);

It is old answer, now

Import android.support.v7.app.AlertDialog instead of android.app.AlertDialog

as given in accepted answer.


Change your code as -

 Dialog alertDialog = new Dialog(this);
    alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alertDialog.setContentView(R.layout.tabs);
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    alertDialog.show();

Or you can add theme to your existing code.

AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);

Import android.support.v7.app.AlertDialog instead of android.app.AlertDialog


if you can access Dialog class, try this:

 alertDialog.getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT);    

before:

dialog_before

after:

dialog_after

Tags:

Android