简体   繁体   中英

Forcing the default Android soft-keyboard to show

I have an activity (forced into protrait mode) that is required to show the default soft-keyboard. So I thought I'd set focus to the edittext when the activity is launched... so far so good.

Two issues

  1. the soft-keyboard shall not be dismiss-able for this activity
  2. the soft-keyboard needs to be elevated 50 pixels from the bottom of the screen

Looking for assistance to solve these two issues. thanks.

to solve #1

private void hideSoftKeyboard()
{
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mAutoCompleteTextView.getApplicationWindowToken(), 0);
}

private void showSoftKeyboard()
{
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,InputMethodManager.HIDE_IMPLICIT_ONLY);
}

#2 has no solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM