I'm using the following code inside my DialogFragment.onCreateView()
to set its gravity on top:
Window window = getDialog().getWindow();
window.setGravity(Gravity.TOP);
This works perfectly on newer Android API versions but not on phones/emulators using Gingerbread (API 9 or 10). I also tried to use the following code on onViewCreated()
without success:
View v = getDialog().getWindow().getDecorView();
WindowManager.LayoutParams lp = (WindowManager.LayoutParams)v.getLayoutParams();
lp.gravity = Gravity.TOP;
getActivity().getWindowManager().updateViewLayout(v, lp);
Any suggestions?