问题分析
AlertDialog默认位置居中此时params.height的值为0,所以要使params.height向上有半个屏幕的偏移量,这样就以Y轴为参考系了。
解决方案
WindowManager.LayoutParams params=dialog.getWindow().getAttributes();
screenHeight=getWindowManager().getDefaultDisplay().getHeight();
params.y= (int) (纵坐标所要在的位置-0.5f*screenHeight);
dialog.getWindow().setAttributes(params);
本文介绍了一种方法,用于调整 Android 中 AlertDialog 的显示位置,使其相对于屏幕 Y 轴进行偏移,实现对话框位置的自定义设置。
1823

被折叠的 条评论
为什么被折叠?



