3

I have a dialog with an EditText, and when the user clicks on it, the soft keyboard appears and pushes the dialog up (so as not to hide it). When the keyboard is dismissed, the EditText resumes its original position. This is standard behavior. The EditText has clearly moved, but calling getLocationOnScreen(), getBottom(), etc return the same result for both positions. Am I missing something here or is this a bug in Android?

By the way, the reason why I ask is because this behavior is causing some of our Robotium tests to fail, because Robotium relies on getLocationOnScreen() to calculate where to click.

migueljuan
  • 405
  • 1
  • 3
  • 12

1 Answers1

0

You need to add android:windowSoftInputMode="adjustResize" to your tag in the AndroidManifest.xml file

OR

Take a look at this

Android: show soft keyboard automatically when focus is on an EditText

This will surely help you.

Thanks :)

Community
  • 1
  • 1
SALMAN
  • 3,909
  • 1
  • 24
  • 21
  • Thanks but I think the title of my question was misleading. I have updated the title - my question is NOT "how do I show the keyboard automatically", rather, "why does `getLocationOnScreen()` return the same result for 2 different positions?" – migueljuan Jul 23 '12 at 11:00