Android:键盘未显示在服务中的窗口管理器对话框中

时间:2016-04-22 08:42:18

标签: focus

我在包含editText的服务中显示自定义对话框。问题是聚焦editText时不会出现软键盘。

Service.java

screenParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE,
            PixelFormat.TRANSLUCENT);
    screenParams.gravity = Gravity.TOP | Gravity.LEFT;
    screenParams.x = 0;
    screenParams.y = 0;
    textLayout.setVisibility(View.VISIBLE);
    editText.requestFocus();
    windowManager.updateViewLayout(screen, screenParams);

layout.xml

<EditText
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:hint="@string/newText"
   android:inputType="textAutoComplete|text"
   android:focusable="true"
   android:focusableInTouchMode="true" />

0 个答案:

没有答案