First, you need to create a white 9-patch. Like panel_background.9.png drawable (which is black), which can be found along the path:
<android-sdk-dir>/platforms/android-
Suppose your drawable is called white_panel_background.9.png .
Option 1.
You can create your own custom theme that extends Theme.Dialog and overrides the windowBackground attribute with a custom white 9 patch.
<style name="Theme.WhiteDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowBackground">@drawable/white_panel_background</item> </style>
And then use this theme in your dialog box:
Dialog dialog = Dialog(context, R.style.Theme_WhiteDialog);
Option 2
If you have already created a dialog box (with a default theme), you can still update its background background:
Dialog dialog = ...; ... Resources res = getResources(); Drawable drawable = res.getDrawable(R.drawable.white_panel_background); dialog.getWindow().setBackgroundDrawable(drawable);
Note. You will need to change the text color from white to black (so it can be seen on a white background).
Note. For AlertDialog, you will need additional steps, as it uses its own background styles. See AlertDialog style for more details.

source share