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.
Using
android.R.style.Theme_Translucent_NoTitleBar
works if you want the dialog to be full screen. An alternative is to create your own style, like so:I added a transparent pixel to drawable and used the following code :
In your resources file create a xml file named for e.g. null_image.xml, with the following content:
In your java code, fetch the dialog window and set the xml file as the drawable resource, like this: Depending on your context:
That's it, enjoy.
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:
Hope this helps someone else.
You can ask the builder to enforce inverse background. Worked for me to display a borderless splash screen with a png source.
Here is my solution, to get a dialog that shows only your content.
themes.xml // located in project /res/values
colors.xml // also located there