android– 从AlertDialog中删除顶部填充?

android– 从AlertDialog中删除顶部填充?,第1张

概述因此我使用默认的Android棒棒糖主题制作了一个AlertDialog并且我的AlertDialog上有这个令人讨厌的顶部填充,我无法弄清楚如何编辑它/摆脱它.这是我用来生成AlertDialog的代码AlertDialog.Builderbuilder;if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIP

因此我使用默认的Android棒棒糖主题制作了一个AlertDialog并且我的AlertDialog上有这个令人讨厌的顶部填充,我无法弄清楚如何编辑它/摆脱它.

这是我用来生成AlertDialog的代码

AlertDialog.Builder builder;            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LolliPOP) {                builder = new AlertDialog.Builder(this, androID.R.style.theme_Material_Dialog_Alert);            } else {                builder = new AlertDialog.Builder(this);            }            builder.setTitle("Found corrupted files")                    .setMessage("We've found " + count + " images that are either missing or " +                            "corrupt. Should we remove these entrIEs from the List?")                    .setPositivebutton("Yeah", new DialogInterface.OnClickListener() {                        @OverrIDe                        public voID onClick(DialogInterface d, int i) {                            MainActivity.this.removeCorruptedImages();                            d.cancel();                        }                    })                    .setNegativebutton("No", new DialogInterface.OnClickListener() {                        @OverrIDe                        public voID onClick(DialogInterface d, int i) {                            d.cancel();                        }                    })                    .setIcon(R.drawable.ic_warning_white_24dp);            AlertDialog al = builder.create();            al.show();

它产生了这个:


我想摆脱标题上方的填充/空白区域.

解决方法:

只需在显示AlertDialog之前尝试此行

AlertDialog al = builder.create();
 al.requestwindowFeature(Window.FEATURE_NO_Title);
 al.show();

总结

以上是内存溢出为你收集整理的android – 从AlertDialog中删除顶部填充?全部内容,希望文章能够帮你解决android – 从AlertDialog中删除顶部填充?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1111347.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存