无法从“活动对话框”中删除填充

时间:2014-01-14 03:11:29

标签: android android-layout xamarin.android xamarin android-ui

我将一个活动设为弹出窗口:

[Activity(Theme="@android:style/Theme.Dialog")]
public class GameOverPopup : Activity

但我总是在我的控件周围贴上白色衬垫(忽略黑色边框,它不是弹出窗口的一部分):

enter image description here

我已经尝试将填充,边距等设置为0dp但总是有额外的空间。

如何删除它?

更新

所以我根据建议尝试了以下内容:

在Styles.xml中:

<style name="PopupDialog" parent="android:style/Theme.Dialog">
   <item name="android:padding">0dp</item>
</style>

然后在我的Activity中(在OnCreate Override中):

SetTheme(Resource.Style.PopupDialog);

然而我仍然有填充:(

2 个答案:

答案 0 :(得分:1)

我记得,Eclipse中自动生成的活动默认包含Android活动范围的边距。如果您使用默认模板,则可以检查以确保在XML布局中删除了这些行。

编辑,总结一些评论并避免创建讨论:问题似乎可能是由于对话框样式中的默认填充。尝试使用该样式创建样式作为其父样式,并根据需要手动设置填充/边距:http://developer.android.com/guide/topics/ui/themes.html#DefiningStyles

答案 1 :(得分:1)

搞定了!!

问题是我在OnCreate AS WELL的代码中设置主题作为活动的属性。所以我从OnCreate中删除了代码并将以下属性放在我的弹出Activity类中:

[Activity(Theme = "@style/PopupDialog")]
public class GameOverPopup : Activity

我的Styles.xml是:

<style name="PopupDialog" parent="android:style/Theme.Dialog">
  <item name="android:windowBackground">@null</item>
  <item name="android:padding">0dp</item>
</style>