Android Dialog 自定义宽度

 1 DialogAppStoreUpdate dialogAppStoreUpdate = new DialogAppStoreUpdate(context, update_detail, update_url);
 2         dialogAppStoreUpdate.show();
 3         WindowManager windowManager = getActivity().getWindowManager();
 4         Display display = windowManager.getDefaultDisplay();
 5         WindowManager.LayoutParams lp = dialogAppStoreUpdate.getWindow().getAttributes();
 6         lp.width = (int) (display.getWidth()); //设置宽度
 7         dialogAppStoreUpdate.getWindow().setAttributes(lp);
 8 
 9 
10   WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
11         layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
12         layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
13         layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
14         getWindow().getDecorView().setPadding(30, 0, 30, 0);
15         getWindow().setAttributes(layoutParams);

 

posted @ 2018-09-13 15:25  HelloStudio  阅读(5859)  评论(0编辑  收藏  举报