首页 > 代码库 > android--自定义ProgressDialog显示位置(其它Dialog子类都可以设置)

android--自定义ProgressDialog显示位置(其它Dialog子类都可以设置)

1、一般情况下,系统默认的Dialog显示位置为屏幕居中:

	pbDialog = new ProgressDialog(MainActivity.this);
	pbDialog.setMessage("请稍等,加载中");
	pbDialog.show();

2、设置Dialog显示位置在屏幕底部:

	pbDialog = new ProgressDialog(MainActivity.this);
	pbDialog.setMessage("请稍等,加载中");

	WindowManager.LayoutParams params = pbDialog.getWindow().getAttributes();
	pbDialog.getWindow().setGravity(Gravity.BOTTOM);
	pbDialog.show();

3、设置Dialog显示位置在屏幕底部,并且距离底部100px:

	pbDialog = new ProgressDialog(MainActivity.this);
	pbDialog.setMessage("请稍等,加载中");

	WindowManager.LayoutParams params = pbDialog.getWindow().getAttributes();
	pbDialog.getWindow().setGravity(Gravity.BOTTOM);
	params.y = 100;
	pbDialog.getWindow().setAttributes(params);
	pbDialog.show();