参考:https://blog.csdn.net/a525942/article/details/56834639
效果:
1. 创建类 PayWayDialog 继承自 Dialog
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pay_dialog);
Window dialogWindow = getWindow(); //得到弹框
dialogWindow.setGravity(Gravity.BOTTOM); //设为在底部
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = AbsListView.LayoutParams.MATCH_PARENT; //宽度设置
lp.y = 0; //离底部距离为0
dialogWindow.setAttributes(lp);
}
2. 自定义 dialog 布局
3. 调用
PayWayDialog payWayDialog = new PayWayDialog(OrderActivity.this);
payWayDialog.show();
点击事件在类 PayWayDialog 中设置