在使用第三方框架PickerView的时候,在自己写的dialog里面显示PickerView选择器,出现选择器是在从dialog的底部弹出的,应该要从屏幕底部弹出
解决方案:我的理解是类似帧布局一样
.isDialog(true).build();
pvTime.show();
Dialog dialog = pvTime.getDialog();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) pvTime.getDialogContainerLayout().getLayoutParams();
layoutParams.leftMargin = 0;
layoutParams.rightMargin = 0;
pvTime.getDialogContainerLayout().setLayoutParams(layoutParams);
if (dialog != null){
Window dialogWindow = dialog.getWindow();
if (dialogWindow != null){
WindowManager.LayoutParams attributes = dialogWindow.getAttributes();
attributes.dimAmount = 0.3f;
attributes.width = WindowManager.LayoutParams.MATCH_PARENT;
attributes.height = WindowManager.LayoutParams.WRAP_CONTENT;
attributes.gravity = Gravity.BOTTOM;
dialogWindow.setAttributes(attributes);
}
}
参考链接:
https://github.com/Bigkoo/Android-PickerView/issues/279
PickerViewGitHub地址: