Dialog/DialogFragment宽度高度修改/全屏,自定义样式
其实Dialog, DialogFragment, Activity 能看到的界面,都是基于Window显示的; 也就是修改样式, 都是在修改window的样式; 所以,本质上方法都是一样的,唯一不同的就是获取window对象的方法不一样; Dialog 通过, getWindow() 获取; Activity 也是通过, getWindow() 获取; DialogFragment 则是getDialog().getWindow()获取; 有了window对象, 就可以开始本文了: 1:修改Dialog中window宽度和高度 //public static final int FILL_PARENT = -1; //public static final int MATCH_PARENT = -1; //public static final int WRAP_CONTENT = -2; dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//注意此处 dialog.setContentView(textView, new ViewGroup.LayoutParams(-2, -2)); dialog.getWindow().setLayout(-1, -2);/