I have an AlertDialog, whose Y is set and set to show on center. It shows perfectly on 2.3 emulator & device, but on 4.1 (emulator & 4.0 device) it shows on more top than expected.
Here’s the code :
AlertDialog adg = scrnDlg.create();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(adg.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
//lp.height = WindowManager.LayoutParams.MATCH_PARENT;
lp.y = 05;
lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
adg.getWindow().setAttributes(lp);
adg.show();
/* working with 2.3 but nt proper position with 4.0
WindowManager.LayoutParams lp = adg.getWindow().getAttributes();
lp.y = 05;
lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
adg.getWindow().setAttributes(lp);
*/
Screen shot of obth versions emulator :

Can any one help me wort out this problem ?
Also this height is perfect for Ld, Md. But for Hd & xD this height seems to be small & more space is left on bottom. How do I set the height based on screen height.
Any help ishighly appreciated.
Thanks
I finally got the above by setting the Gravity by testing the Android OS Version. This is how I did and get resutls as expected :
Gravity of LayoutParams are treated differently by 4.1 and below 4.1 versions of the Android, thus the above is set and works perfectly.
Hope this sharing help someone.