tags:

views:

123

answers:

1

I'm trying to get a custom dialog with a transparent background doing this way:

this.getWindow().setBackgroundDrawableResource(R.drawable.transparent);

(where "R.drawable.transparent" is a reference to the color "#00000000")

The weird issue on this is that I can't align my dialog window. It's always aligned to the left, even if I implicit set the Gravity of the window using:

this.getWindow().setGravity(Gravity.CENTER);

And if I just comment the line which set the transparent background, the alignment works fine.

Any help would be much appreciated!

Thanks.

A: 

You need to set the padding on the dialog window.

mbaird
I don't want to set paddings or margins, I just want to center the window. Have in mind that I would be needing a relative padding/margin depending on the display screen width and height and that would be a ugly fix :( Is there any problem with the transparent background?I noticed that using a very similar transparent color "#01000000" (just incremented the opacity in 1) it works fine. Android bug? :S
feragusper
So I had the same problem you are having now, and I did the following: android:layout_margin="20dip" and it fixed it to my satisfaction. Note that I'm using device independent pixels, so it keeps the margin the same visually across different screen resolutions.
mbaird