问题描述
我想地方,使用以下code在OnCreate()中使用Holo.Dialog主题我的应用程序的左上角一个Android活动:
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;
(这是单声道Android设备)
(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:
注意菜单框和屏幕的实际边缘之间的间隙。
我能做些什么完全地消除这个差距?
Notice the gap between the menu box and the actual edge of the screen.What can I do to remove that gap completly?
推荐答案
原来,问题很简单:Theme.Holo.Dialog定义的背景下,增加了对话围绕一个透明边框。这会导致角和对话之间的间距
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.
这篇关于活动的对话框:放置在左上角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!