首页 > 代码库 > 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();


android--自己定义ProgressDialog显示位置(其他Dialog子类都能够设置)