Reputation: 10287
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?
Upvotes: 2
Views: 216
Reputation: 16570
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:
Button
you say dissapears in a ScrollView
. The ScrollView
will then wrap its content to allow the Button
to be shown in between the keyboard and the ScrollView
.Upvotes: 2
Reputation: 4945
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!
Upvotes: 1
Reputation: 6712
The answer is to set the focus on an other View like a Button, TextView or similar:
// REQUEST FOCUS
viewName.setFocusableInTouchMode(true);
viewName.requestFocus();
Upvotes: 1