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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzpzdx.html