- public class SharePost extends Dialog
- {
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.adaptor_contentsharepost);
- LayoutParams params = getWindow().getAttributes();
- params.height = LayoutParams.FILL_PARENT;
- getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
- }
- }
还有:
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.show();
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = 200; params.height = 200 ;
dialog.getWindow().setAttributes(params);
- WindowManager m = getWindowManager();
- Display d = m.getDefaultDisplay(); //为获取屏幕宽、高
- LayoutParams p = getWindow().getAttributes(); //获取对话框当前的参数值
- p.height = (int) (d.getHeight() * 0.6); //高度设置为屏幕的0.6
- p.width = (int) (d.getWidth() * 0.95); //宽度设置为屏幕的0.95
- getWindow().setAttributes(p); //设置生效