<tfoot id='sQUTs'></tfoot>

    <legend id='sQUTs'><style id='sQUTs'><dir id='sQUTs'><q id='sQUTs'></q></dir></style></legend>
      <bdo id='sQUTs'></bdo><ul id='sQUTs'></ul>

      <i id='sQUTs'><tr id='sQUTs'><dt id='sQUTs'><q id='sQUTs'><span id='sQUTs'><b id='sQUTs'><form id='sQUTs'><ins id='sQUTs'></ins><ul id='sQUTs'></ul><sub id='sQUTs'></sub></form><legend id='sQUTs'></legend><bdo id='sQUTs'><pre id='sQUTs'><center id='sQUTs'></center></pre></bdo></b><th id='sQUTs'></th></span></q></dt></tr></i><div id='sQUTs'><tfoot id='sQUTs'></tfoot><dl id='sQUTs'><fieldset id='sQUTs'></fieldset></dl></div>
    1. <small id='sQUTs'></small><noframes id='sQUTs'>

    2. Android - 键盘未出现在浮动窗口中

      时间:2023-10-01

      <tfoot id='8TISY'></tfoot>
      <i id='8TISY'><tr id='8TISY'><dt id='8TISY'><q id='8TISY'><span id='8TISY'><b id='8TISY'><form id='8TISY'><ins id='8TISY'></ins><ul id='8TISY'></ul><sub id='8TISY'></sub></form><legend id='8TISY'></legend><bdo id='8TISY'><pre id='8TISY'><center id='8TISY'></center></pre></bdo></b><th id='8TISY'></th></span></q></dt></tr></i><div id='8TISY'><tfoot id='8TISY'></tfoot><dl id='8TISY'><fieldset id='8TISY'></fieldset></dl></div>

        <tbody id='8TISY'></tbody>

            <legend id='8TISY'><style id='8TISY'><dir id='8TISY'><q id='8TISY'></q></dir></style></legend>
                <bdo id='8TISY'></bdo><ul id='8TISY'></ul>

                <small id='8TISY'></small><noframes id='8TISY'>

                本文介绍了Android - 键盘未出现在浮动窗口中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在编写一个应用程序,它使用以下代码在正在运行的应用程序的屏幕上绘制编辑文本:

                I'm writing an application that uses the following code to draw an edittext on the screen over running applications:

                WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                                WindowManager.LayoutParams.WRAP_CONTENT,
                                WindowManager.LayoutParams.WRAP_CONTENT,
                                WindowManager.LayoutParams.TYPE_PHONE,
                                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                                    | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                                PixelFormat.TRANSLUCENT);
                
                windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
                
                windowManager.addView(mEditText, params);
                

                edittext的xml是:

                The xml for the edittext is:

                <EditText
                            android:id="@+id/mEditText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:maxLines="3"
                            android:inputType="textAutoComplete|text"
                            android:focusable="true"
                            android:focusableInTouchMode="true" />
                

                但是,专注于此并不会调出键盘.我还尝试通过 onFocusListener 以编程方式提出它:

                However focusing on this does not bring up the keyboard. I've also tried programmatically bringing it up with an onFocusListener:

                mEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                            @Override
                            public void onFocusChange(View v, boolean hasFocus) {
                                if(hasFocus) {
                                    Log.d("", "Has focus");
                                    ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
                                } else {
                                    Log.d("", "Lost focus");
                                }
                            }
                        });
                

                但是,从 logcat 中可以看出,尽管调用了它,但什么也没发生.到目前为止,我发现显示键盘的唯一方法是使用:

                But although that is called, as seen from the logcat, nothing happens. The only method I've found so far to display the keyboard is using:

                getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, 0);
                

                但这似乎是在屏幕上输入而不是在编辑文本中.当显示编辑文本时,我也尝试过清晰可聚焦,但无济于事.

                But that seems to type onto the screen and not into the edittext. I've also tried clear focusable when the edittext is displayed but to no avail.

                我猜这个问题是因为我使用的是浮动窗口",但必须有一种方法可以使这项工作成为可能,因为 Playstore 中存在浮动计算器等应用程序,它们需要输入.有人有什么想法吗?我被难住了:(

                I'm guessing the issue is because I'm using a "floating window" but there must be a way to make this work as apps such as floating calculators exist on the playstore which take input.. Anyone have any ideas? I'm stumped :(

                推荐答案

                我的错.. 我意识到如果我删除 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 它可以正常工作.. 愚蠢的错误

                My bad.. I realized if I remove the WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE it works fine.. silly mistake

                这篇关于Android - 键盘未出现在浮动窗口中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在android中以编程方式设置编辑文本提示? 下一篇:在 Android 项目中使用 EditText.toString() 方法获取奇

                相关文章

                最新文章

                <tfoot id='fwyfl'></tfoot>

                <i id='fwyfl'><tr id='fwyfl'><dt id='fwyfl'><q id='fwyfl'><span id='fwyfl'><b id='fwyfl'><form id='fwyfl'><ins id='fwyfl'></ins><ul id='fwyfl'></ul><sub id='fwyfl'></sub></form><legend id='fwyfl'></legend><bdo id='fwyfl'><pre id='fwyfl'><center id='fwyfl'></center></pre></bdo></b><th id='fwyfl'></th></span></q></dt></tr></i><div id='fwyfl'><tfoot id='fwyfl'></tfoot><dl id='fwyfl'><fieldset id='fwyfl'></fieldset></dl></div>
                <legend id='fwyfl'><style id='fwyfl'><dir id='fwyfl'><q id='fwyfl'></q></dir></style></legend>

                  • <bdo id='fwyfl'></bdo><ul id='fwyfl'></ul>
                  1. <small id='fwyfl'></small><noframes id='fwyfl'>