android 自定义Dialog如何控制View显示位置/大小

底部显示View:
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = getWindow();
lp.copyFrom(window.getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity = Gravity.BOTTOM;
window.setAttributes(lp);

控制view大小:
final int screenHeight = ScreenUtil.getDisplayHeight(this.mContext);
int height = (int) (screenHeight * 0.58);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(width, height);
this.mDialog.addContentView(mRootView, params);
this.mDialog.show();

你可能感兴趣的:(android 自定义Dialog如何控制View显示位置/大小)