一、Dialog概述
二、使用系统自带的Dialog
1、新建Builder
AlertDialog.Builder builder = new AlertDialog.Builder(StoryActivity.this);
dialog.show();
2、通过builder创建dialog
1 2 3 4 5 6 
  | AlertDialog dialog = builder.setView(view).setTitle("查看评论").setNegativeButton("确定", new 	DialogInterface.OnClickListener() { 		@Override 		public void onClick(DialogInterface dialog, int which) { 			dialog.dismiss(); 		}     	}).create(); 
  | 
 
早期版本,NegativeButton最右侧、PositiveButton最左侧、NeutralButton中间

在android4.0中,NegativeButton在最左侧、PositiveButton在最右侧

二、如何自定义Dialog
1、特别注意!!!(首先明确)
1.1 setContentView、setView与show()方法相对位置引起异常
如使用setContentView、setView方法来自定义View的话,须与show()方法保持先后顺序
1 2 
  | dialog.show(); dialog.setContentView(contentView); 
  | 
 
2.2 自定义Dilog之后,setTitle等方法无效
须自行在界面中添加
2、步骤同上
3、设置界面
使用以下方法实现自定义界面
1 2 3 4 5 
  | setView(View view) setView(View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight,int viewSpacingBottom) setContentView(@LayoutRes int layoutResID) setContentView(View view) setContentView(View view, ViewGroup.LayoutParams params)	//params Layout parameters for the view. 
  | 
 
4、自定义Dialog的宽高
1 2 3 4 
  | Window window = this.getWindow(); WindowManager.LayoutParams params = window.getAttributes(); params.height = dialogHeight;	//设置你想要的宽高 window.setAttributes(params); 
  | 
 
5、获得屏幕的宽高
1 2 3 
  | DisplayMetrics d = context.getResources().getDisplayMetrics();	// 获取屏幕宽、高 d.heightPixels	//取得px单位的值 d.xdpi	//取得dp单位的值 
  |