android自定义对话框和弹出框

// 设置对话框的弹出位置
private void showDialog_Layout(Context context) {


final AlertDialog dlg = new AlertDialog.Builder(this).create();
dlg.show();
Window window = dlg.getWindow();


// *** 主要就是在这里实现这种效果的.
// 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容
window.setContentView(R.layout.membership_manage_search_number);


window.setWindowAnimations(R.style.dialogWindowAnim);
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;
wl.y = -68;
window.setAttributes(wl);
// 为确认按钮添加事件,执行退出应用操作
Button search_button = (Button) window.findViewById(R.id.search_button);


search_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {


}
});
}


private void showPopupWindow() {


View view = (LinearLayout) LayoutInflater.from(
MembershipManagerActivity.this).inflate(
R.layout.membership_manage_search_number, null);


if (popupWindow == null) {


popupWindow = new PopupWindow(MembershipManagerActivity.this);
popupWindow.setBackgroundDrawable(new BitmapDrawable());


// popupWindow.setFocusable(true); // 设置PopupWindow可获得焦点
popupWindow.setTouchable(true); // 设置PopupWindow可触摸
popupWindow.setOutsideTouchable(true); // 设置非PopupWindow区域可触摸
popupWindow.setContentView(view);
popupWindow.setWidth(LayoutParams.MATCH_PARENT);
popupWindow.setHeight(LayoutParams.WRAP_CONTENT);
popupWindow.setAnimationStyle(R.style.dialogWindowAnim); // 设置popupWindow动画样式


}
popupWindow.showAtLocation(view, Gravity.TOP | Gravity.CENTER, 0, 76);
popupWindow.update();
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值