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.
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:
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; }
And that’s it! Source code lives on GitHub here.
About this entry
You’re currently reading “ LightBox Effect for Android Dialogs ,” an entry on Public Static Droid Main
- Published:
- 6.12.12 / 11am
- Category:
- Uncategorized
No comments
Jump to comment form | comments rss [?] | trackback uri [?]