tags:

views:

1082

answers:

1

I have created an AlertDialog using AlertDialog.Builder, but the Dialog border takes up too much space on the screen. How do I remove the border? I have tried using another Activity to emulate the dialog with a transparent background, but the dialog is used repeatedly, and creating a new Activity every time introduces a significant amount of lag.

The answer from here mentions that it can be found in the ApiDemos, but i can't seem to find it.

+3  A: 

Alright, I'll answer my own question. Basically, instead of using AlertDialog.Builder, create a regular Dialog using it's constructor, and use a suitable theme instead of the default Dialog theme.

So your code would look something like this:

Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);

Hope this helps someone else.

spaceboy2000
if we do this then dialog.setCanceledOnTouchOutside(true); will have no effect... how to handle this then?
Amith GC
That is exactly what I was looking for. I've been wrestling with the dialog creation system and dozens of badly written tutorials for hours now, and your one line of code was all I needed. Thank you!
kodi