AlertDialog:是一种警告,提醒对话框;
Builder的创建(是AlertDialog的辅助类,用于创建AlertDialog实例,以及属性的设置)
AlertDialog.Builder builder =newAlertDialog.Builder(Context context);
设置自定义style属性
AlertDialog.Builder builder =newAlertDialog.Builder(Context context,int id);
@null
true
false
true
@drawable/ic_launch
false
0.5
@anim/out
@anim/off
设置window的属性----窗口的大小
Window window = dialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
//设置宽度和高度
lp.width= WindowManager.LayoutParams.MATCH_PARENT;
lp.height= WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(lp);
设置window的属性----窗口的位置
LayoutParams params =new LayoutParams();
params.x = -80;//设置x坐标
params.y = -60;//设置y坐标
//设置屏幕不变成灰色
params.flags= WindowManager.LayoutParams.*FLAG_BLUR_BEHIND*
params.gravity= Gravity.BOTTOM;
win.setAttributes(params);
window.setGravity(Gravity.*TOP*);
点击Dialog以外范围DIalog不消失:
dialog.setCanceledOnTouchOutside(false);
总结: