My app has an EditText that, when I click in it to enter text in the Emulator, brings up a soft keyboard. I don't want this confounded thing to begin with, but then, like the visiting loud-mouthed uncle in the plaid pants, doesn't want to go away, and it is blocking the button beneath it. How do I either (a) prorgrammatically prevent the soft keyboard from appearing or at least (b) evict it, albeit manually, when it pops up?

- 8,547
- 144
- 472
- 862
-
1Is the user suposed to type stuff in the `EditText`? – kaspermoerch Dec 16 '11 at 12:21
-
Yes, that's the intent (no pun intended). – B. Clay Shannon-B. Crow Raven Dec 16 '11 at 12:30
-
So you want the user to type stuff, but you don't want the keyboard to be shown? – kaspermoerch Dec 16 '11 at 12:35
-
How will you type without the keyboard? – Mohit Verma Dec 16 '11 at 12:53
-
I guess my cover is blown - I don't have a SmartPhone yet, so forgot that the way the Emulator works is not the way a "real" phone works (in the Emulator, I simply click in the Edit and type, as I would in a "regular" software app). Still, though, how does a user "get rid of" the soft keyboard once they're through with it. Or at least, how do _I_ get rid of it in the Emulator, so that I can click the button that it's covering up? – B. Clay Shannon-B. Crow Raven Dec 17 '11 at 22:01
4 Answers
Provided that the user is not supposed to input text, but is able to click the EditText
and then add text in some other way, you could change the EditText
to a TextView
and then apply the following three tags to it in the layout file:
style="@android:style/Widget.EditText"
android:editable="false"
android:focusableInTouchMode="false"
This will make it look like an EditText
, but behave like a TextView
.
Since you want the user to be able to write stuff in the EditText
there are in my opinion two solutions:
- Leave it be. To remove the keyboard, all you need is to hit the back button once and every Android user knows this. It's standard behaviour.
- Wrap everything but the
Button
you say dissapears in aScrollView
. TheScrollView
will then wrap its content to allow theButton
to be shown in between the keyboard and theScrollView
.

- 16,127
- 4
- 44
- 67
The answer is to set the focus on an other View like a Button, TextView or similar:
// REQUEST FOCUS
viewName.setFocusableInTouchMode(true);
viewName.requestFocus();

- 6,692
- 2
- 25
- 30
-
I want the user to be able to enter the EditText; I just don't want the soft keyboard to monopolize the bottom of the screen/Activity. – B. Clay Shannon-B. Crow Raven Dec 16 '11 at 12:33
Just set android:editable="false" for your EditText

- 6,328
- 12
- 52
- 84
-
I want it to be editable, though; I just want to prevent the soft keyboard from being invoked. – B. Clay Shannon-B. Crow Raven Dec 16 '11 at 12:33
I think what you really need is take a look at android:windowSoftInputMode
attribute in Manifest.xml
Look into this link.
You can specify the screen to pan/ resize to show the buttons that the input method might be blocking. Not allowing the keyboard to show will make the user unable to enter text at all!

- 4,875
- 3
- 25
- 30