Add following property into your activity tag (AndroidManifest.xml)
android:windowSoftInputMode="adjustResize"
Also you need to add below code in OnCreate function (MainActivity.java)
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
This solved the problem and it worked perfectly fine on all resolution emulators and samsung devices. It did fail, though, on Google Nexus S device and I could see the same problem again of virtual keyboard hiding the EditTexts.
You can try below code to make dialog adjustable as per keyboard status.
alertDialog.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Note -: If you are using Dialog instead of alert Dialog do the below changes.
Create one style file e.g. dialog.xml. Put below code into it.
<style name="DialogStyle" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowFullscreen">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowSoftInputMode">stateUnchanged</item>
<item name="android:windowBackground">#22AAEA</item>
</style>
Now apply style to dialog.
final Dialog dialog = new Dialog(this , R.style.dialog);
NOTICE that the attribute "parent" is "Theme.Black.NoTitleBar.Fullscreen" like a activity's style. and the attribute "android:windowFullScreen" should be false.
Now, the dialog will be resized when the soft keyboard toggled.