0

I'm trying to place an Android activity that uses the Holo.Dialog theme in the top left corner of my application by using the following code in OnCreate():

var layoutParams = this.Window.Attributes;
layoutParams.Gravity = GravityFlags.Top | GravityFlags.Left;

(This is Mono for Android)

It kind of works, however there is a tiny gap between the actual corner and the beginning of my dialog, which you can see in the following screen shot:

https://www.dropbox.com/s/cyy9lglq5642nz1/device-2013-05-26-223855.png

Notice the gap between the menu box and the actual edge of the screen. What can I do to remove that gap completly?

Nate
  • 31,017
  • 13
  • 83
  • 207
cguedel
  • 1,092
  • 1
  • 14
  • 28
  • May [this](http://stackoverflow.com/questions/5469005/show-alertdialog-in-any-position-of-the-screen) helps you ;) – Oli May 26 '13 at 20:44
  • I don't see how this could help. I already set the gravity, the dialog aligns to the top left corner, however there is a gap, and that's my problem. Additionally, if I set layoutParams.X to 0, the gap is still present. – cguedel May 27 '13 at 06:25

1 Answers1

1

Turns out the problem is rather simple: Theme.Holo.Dialog defines a background that adds a transparent border around the dialog. This causes the spacing between the corner and the dialog.

Creating a custom style fixes it:

<style name="MyCustomDialog" parent="android:Theme.Holo.Dialog">
    <item name="android:windowBackground">@null</item>
</style>

This overwrites the background and removes the spacing.

cguedel
  • 1,092
  • 1
  • 14
  • 28