android 修改AlertDialog的黑色背景的两种方式及圆角边框的设置 |
您所在的位置:网站首页 › 安卓手机黑色主题怎么设置 › android 修改AlertDialog的黑色背景的两种方式及圆角边框的设置 |
修改黑色背景
第一种方式
直接使用AlertDialog.Builder的方法 AlertDialog dialog = new AlertDialog.Builder(this) .create(); dialog.setInverseBackgroundForced(true);// 背景变成了白色 第二种方式自定义一个布局,在dialog显示之后,重新设置dialog的内容view AlertDialog dialog = new AlertDialog.Builder(this) .create(); dialog.show(); Window window = dialog.getWindow(); window.setContentView(R.layout.custom_alert_dialog); // 设置背景透明 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));注意:一定要在show()方法之后重新设置布局。至于为什么,实践出真知 AlertDialog的圆角边框设置修改Alertdialog黑色背景的第二种方式的布局文件R.layout.custom_alert_dialog的背景为圆角边框即可 下面是布局及圆角的代码 R.layout.custom_alert_dialog.xml 圆角,bg_dialog.xml 修改自https://www.cnblogs.com/yaowukonga/archive/2012/05/19/2508743.html https://blog.csdn.net/csdnzouqi/article/details/84337004 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |