当我运行这段代码时,会显示警告对话框,但对话框周围有一个白色边框,而且边框有点圆。我不想要这个白色边框,我想要真正的 90 角角。我希望你明白我想做什么。
AlertDialog.Builder ad = new AlertDialog.Builder(this);
Button bbb=new Button(MvcnContactList.this);
ad.setView(bbb);
alertDialog = ad.create();
alertDialog.show();
有什么方法可以设置警报对话框的样式而不是文本颜色或文本大小或类似的东西...我想设置警报对话框的边框样式,所以只设置一个主题可能是解决这个问题的方法。但我不知道要覆盖哪些属性。
谢谢,
编辑: 例如,这种样式将 textColor 覆盖为 00FF00 ,这很酷,但是我应该覆盖哪个属性以使角不圆并删除那个白色的 boreder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AlertDialogCustom" parent="@android:style/AlertDialog">
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
<item name="android:textSize">10sp</item>
</style>
</resources>
最佳答案
我找到了包装器的解决方案,您可以在其中将主题(样式)设置为当前上下文中的任何内容。我将 R.style.MyTheme 设置为我的警报对话框的样式,并根据自己的喜好自定义了该 View 。
ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.MyTheme );
AlertDialog.Builder builder= new AlertDialog.Builder( ctw );
关于android - 更改 AlertDialog 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8011899/