Custom Alert dialog not centered vertically on Android Custom Alert dialog not centered vertically on Android android android

Custom Alert dialog not centered vertically on Android


The bug is described here. The AlertDialog is reserving space for the title/icon panel even where there is neither a title nor an icon.

The fix is, I think, quite simple: it should set the top panel layout to GONE, just as it does for the button panel in the event of there being no buttons. Until that's done, the only workaround is to implement your own Dialog subclass.


If you implement your own dialog the line requestWindowFeature(Window.FEATURE_NO_TITLE) hides the title panel and the dialog is centered on the screen. Maybe it works with a AlertDialog too.


You can use an Activity instead of a custom alert for this. You have to set the theme of activity as dialog in the android manifest file:

android:theme="@android:style/Theme.Dialog"

And you can adjust the activity xml layout as per your need.