dialog 屏幕居中
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);关键代码,设置NoTitie 或者在属性中设置 android:windowNoTitle
以下代码是设置dialog的位置在屏幕中的任意
http://stackoverflow.com/questions/5469005/show-alertdialog-in-any-position-of-the-screen
private CharSequence[] items = {"Set as Ringtone", "Set as Alarm"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if(item == 0) { } else if(item == 1) { } else if(item == 2) { } } }); AlertDialog dialog = builder.create(); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes(); wmlp.gravity = Gravity.TOP | Gravity.LEFT; wmlp.x = 100; //x position wmlp.y = 100; //y position dialog.show();