Android: Resize AlertDialog when keyboard is shown

There are times you have to show some text fields on the dialog, and when the keyboard pops up it becomes an absolute nuisance.


As you can see, the keyboard is covering the OK/Cancel buttons. In other cases it covers auto-complete or spinner items.

Thankfully, there's a quick and easy one liner that'll fix you right up. The last line is the one of particular interest to you.

AlertDialog d;
d = new AlertDialog.Builder(this);


Make sure you have some sort of resizable element in the layout to accommodate for the reduction of screen space (such as a ScrollView).

Don't worry Android keyboard, we still love you!


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog