http://blog.csdn.net/jdfkldjlkjdl/article/details/52233737
- imageDialog.show();
- Window window = imageDialog.getWindow();
- if (imageDialog != null && window != null) {
- window.getDecorView().setPadding(0, 0, 0, 0);
- WindowManager.LayoutParams attr = window.getAttributes();
- if (attr != null) {
- attr.height = ViewGroup.LayoutParams.WRAP_CONTENT;
- attr.width = ViewGroup.LayoutParams.MATCH_PARENT;
- attr.gravity = Gravity.BOTTOM;
-
- window.setAttributes(attr);
- }
- }
imageDialog为我们定义的对话框,在imageDialog.show()后面加这一段代码,可以实现从底部弹窗,并且占据整个屏幕宽度的对话框,因为我发现dialog 默认的样式@android:style/Theme.Dialog 对应的style 有pading属性,所以
win.getDecorView().setPadding(0, 0, 0, 0); 就能够水平占满了在此记录之,以备重用。