美文网首页
android 自定义Dialog如何控制View显示位置/大小

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

作者: 塑料机霸 | 来源:发表于2018-03-09 01:34 被阅读60次

    底部显示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显示位置/大小

          本文链接:https://www.haomeiwen.com/subject/ikgufftx.html