Android 3.1 soft keyboard in fullscreen mode

前端 未结 2 1236
小鲜肉
小鲜肉 2020-12-31 10:02

I\'m developing an application for Android 3.1. Is there a way to show (or forcing) the Android keyboard in fullscreen mode?

相关标签:
2条回答
  • 2020-12-31 10:10

    here comes two util functions, hope it helps

    public static void showSoftKeyboard (Context context, View view) {
            try {
                ((InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE))
                .showSoftInput(view, InputMethodManager.SHOW_FORCED);
            }
            catch (Exception ex) {
                Log.w(TAG, "showSoftKeyboard->"+ex.toString());
            }
        }
        public static void hideSoftKeyboard (Context context, View view) {
            try {
                InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
            }
            catch (Exception ex) {
                Log.w(TAG, "hideSoftKeyboard->"+ex.toString());
            }
        }
    


    ...
    Social Coding @ AspiroTV

    0 讨论(0)
  • 2020-12-31 10:20

    Try:

    activity.getWindow().setSoftInputMode(
                            WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    

    To hide, or:

    activity.getWindow().setSoftInputMode(
                            WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    

    or:

    activity.getWindow().setSoftInputMode(
                            WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    

    One of these should help you :)

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题