LightBox Effect for Android Dialogs

The stock black rectangular progress dialogs on Android are ugly, so I created a simple little open-source alternative.

It works by placing a translucent overlay on the Android UI with a ProgressBar and a dialog message. There’s also an alpha animation in there, to really class it up.

Lightbox

To use it, just add the lightbox_dialog.xml file to your res/layout folder. Then add the styles.xml and colors.xml to your res/values folder.

Then, just define these methods and dialog somewhere in an Activity base class:
[java]
private Dialog busyDialog;

public void showBusyDialog(String message) {
busyDialog = new Dialog(this, R.style.lightbox_dialog);
busyDialog.setContentView(R.layout.lightbox_dialog);
((TextView)busyDialog.findViewById(R.id.dialogText)).setText(message);

busyDialog.show();
}

public void dismissBusyDialog() {
if (busyDialog != null)
busyDialog.dismiss();

busyDialog = null;
}
[/java]
And that’s it! Source code lives on GitHub here.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *