Sunday, August 11, 2013

Observation On Android OS About The Keyboard

The other day i encountered a baffling problem, where no matter what i did, the android keyboard wouldnt appear on activity startup, even though the editText was in focus, i even tried explicitly calling it, but no luck.

But heres the catch, when you wrap the focusable editTexts in a scrollView the keyboard shows up automatically, no need to call it at all. The scrollView collapses and the keyboard shows.

I tested a theory, and seems apparently true, though i could find no reference to it on the net, the android OS seems to block the keyboard from automatically being shown (even if explicitly called), if its going to show up over a focusable field (anything you can type in).

This makes sense since you would like to see what your typing when your typing it! Now for the reason it works with the scrollView, its quite simple, the andoird OS can keep the field in view by scrolling the view, so it isnt  a problem.

I havent found a way to override this feature, but the soultion seems viable and logical, wrapping activity components in a scrollview.

BEST PRACTICE : Have a scrollView at the activity base.

Well comments and views are welcome, till next time!

Device Information:

No comments:

Post a Comment