Bigkoo / Android-PickerView

This is a picker view for android , support linkage effect, timepicker and optionspicker.(时间选择器、省市区三级联动)
Apache License 2.0
13.44k stars 3.45k forks source link

帮忙解决对话框两边有间距问题 #885

Open chenni521 opened 4 years ago

chenni521 commented 4 years ago

我自己用的一个PopupWindow 点击出来 然后来选择时间 出现的问题有 isDialog 不使用对话框模式 上面不会有阴影 或者没吧 PopupWindow 遮住 用了对话框 放在底部两边有间距 如下解决代码 Dialog mDialog = pvTime.getDialog(); pvTime.show(); if (mDialog != null) { Window dialogWindow = mDialog.getWindow(); if (dialogWindow != null) { //去除系统自带的margin dialogWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //设置dialog在界面中的属性 dialogWindow.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); } dialogWindow.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.grayf2)));//可以和你对话框的底色一样 dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示 }

DL-ZhangTeng commented 2 years ago

FrameLayout content = dialogWindow.getDecorView().findViewById(R.id.content_container); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) content.getLayoutParams(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; //这一行可删除两边有间距 layoutParams.leftMargin = 0; layoutParams.rightMargin = 0; content.setLayoutParams(layoutParams);