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);

猜你喜欢

转载自www.cnblogs.com/hello-studio/p/9640757.html