Reputation: 7198
How can I force display the virtual keyboard in landscape mode in startup of the activity? and this keyboard doesn't fill the entire screen so I can display some views above the keyboard.
Upvotes: 1
Views: 2478
Reputation: 10682
This is the only combination that worked for me:
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
View view = this.getCurrentFocus();
if (view != null && imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
and to show it:
private void showKeyboard(View view){
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(view, 0);
}
}
I also added android:imeOptions="flagNoExtractUi"
to the view in XML.
Upvotes: 0
Reputation: 28379
Please refer to my answer at a similar question here: How to open only half keyboard in Landscape mode?
For the solution.
You'll need to introduce an attribute of android:imeOptions="flagNoExtractUi"
into your xml to produce the effect you seek.
Upvotes: 1
Reputation: 272
I guess you are talking to force to show the soft keyboard in landscape mode in a device with hard keyboard, right?
We can do this by following code:
InputMethodManager input = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if(input != null)
input.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
Upvotes: 0