[英]android eclipse alertdialog double box
我已经为我的android应用创建了一个alertdialog框,但是我似乎在Alert框中得到了2个框。
下面是我的警报框代码;
AlertDialog.Builder AlertBox = new AlertDialog.Builder(Login.this, android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth);
AlertBox.setTitle("Alert");
AlertBox.setMessage("Username or password is incorrect.");
AlertBox.setNeutralButton("OK", null);
AlertBox.show();
我是否正在做一些显而易见的事情导致此? 我如何摆脱alertdialog后面的框。
提前致谢。
更改
AlertDialog.Builder AlertBox = new AlertDialog.Builder(Login.this, android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth);
至
AlertDialog.Builder AlertBox = new AlertDialog.Builder(Login.this);
在AndroidManifest.xml中设置样式
new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT);
您会看到它指向com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert
看起来像:
<style name="Theme.Holo.Light.Dialog.Alert">
<item name="windowBackground">@android:color/transparent</item>
<item name="windowTitleStyle">@android:style/DialogWindowTitle.Holo.Light</item>
<item name="windowContentOverlay">@null</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
</style>
当您查看主题时,您将应用android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth
,您将发现:
<style name="Theme.Holo.Light.Dialog.NoActionBar.MinWidth">
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
</style>
它们的主要区别在于android:windowBackground
属性。
如果使用Theme.Holo.Light.Dialog.NoActionBar.MinWidth
作为父级来创建自己的样式并应用android:windowBackground
属性,则会发现“双框”不再可见,而是透明的:
<style name="Your.Theme" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar.MinWidth">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
为了突出这一点,将android:windowBackground
属性设置为@android:color/holo_red_light
:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.