设置Dialog全屏,背景使用Dialog布局颜色
2016-06-22 14:41
274 查看
通过搜索引擎找了不少答案,但是没有一个能解决我的问题,大多数人的需求都是去掉黑色背景,然后只能自己尝试。
最后通过代码来设置实现了我需要的效果。
需要背景是什么颜色,就在dialog的xml根布局中设置吧O(∩_∩)O!
最后通过代码来设置实现了我需要的效果。
<style name="dialog" > <item name="android:windowNoTitle">true</item> </style> // style需要自己写,只用消除title属性就够了,也不用设置parent Dialog dialog = new Dialog(context,R.style.dialog); dialog.setContentView(R.layout.dialog); WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); // 设置宽高为match_parent,不要去算出来屏幕宽高再赋值哦,因为有些 // 有虚拟按键的手机上计算出来的高度不一定准确,所以dialog不会全屏 params.width = WindowManager.LayoutParams.MATCH_PARENT; params.heigth = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(params); // 设置dialog距屏幕的边距都为0 dialog.getWindow().getDecorView().setPadding(0,0,0,0); dialog.show();
需要背景是什么颜色,就在dialog的xml根布局中设置吧O(∩_∩)O!
相关文章推荐
- DWZ刷新dialog解决方法
- C#及WPF获取本机所有字体和颜色的方法
- ScrollView滚动条颜色的设置方法
- C#实现HSL颜色值转换为RGB的方法
- 颜色快速采集器javascript代码
- js+HTML5实现canvas多种颜色渐变效果的方法
- MC Dialog js弹出层 完美兼容多浏览器(5.6更新)
- javascript实现通过表格绘制颜色填充矩形的方法
- js Dialog 去掉右上角的X关闭功能
- js随机颜色代码的多种实现方式
- jquery BS,dialog控件自适应大小
- jQuery EasyUI Dialog拖不下来如何解决
- jquery ui dialog实现弹窗特效的思路及代码
- JQUERY dialog的用法详细解析
- jquery ui dialog替代confirm实例分析
- JavaScript实现把rgb颜色转换成16进制颜色的方法
- jQuery实现dialog设置focus焦点的方法
- Javascript实现颜色rgb与16进制转换的方法
- js实现正方形颜色从下往上升的效果
- Locate a File Using a File Open Dialog Box