首页 > 代码库 > AlertDialog 设定位置

AlertDialog 设定位置

AlertDialog alert = new AlertDialog.Builder(this).create(); 

 
WindowManager.LayoutParams lp =alert.getWindow().getAttributes();
// lp.x=0;
lp.y=100;

alert.show(); 
alert.getWindow().setGravity(Gravity.CENTER);
alert.getWindow().setLayout( 
android.view.WindowManager.LayoutParams.WRAP_CONTENT, 
android.view.WindowManager.LayoutParams.WRAP_CONTENT); 

alert.getWindow().setContentView(R.layout.top_items);

AlertDialog 设定位置