Android WebView 输入类型 ="text"光标未显示

标签 android webview

当我在 WebView 中单击输入文本字段 (input type="text") 时,该字段显示软键盘但未显示光标。 我可以输入文本,但没有光标... 发生这种情况时,Logcat 会显示 “W/IInputConnectionWrapper:非 Activity InputConnection 上的 showStatusIcon”或“W/IInputConnectionWrapper:非 Activity InputConnection 上的 getTextBeforeCursor”。 我试图覆盖我的 WebView 使 onCheckIsTextEditor() 返回 true;,但没有任何效果。 请帮忙。

最佳答案

我通过将 focusable 设置为 WebView 的封闭 View 解决了这个问题。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true"
    android:focusableInTouchMode="true">
    <WebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    <include
        android:id="@+id/progress_bar"
        layout="@layout/progress_bar"/>
</FrameLayout>

关于Android WebView 输入类型 ="text"光标未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30972568/

相关文章:

java - 替换 Android 默认字体文件

android - 如何在 App Inventor 中打开网页

java - 交换 ListView 项目中的图标

css - 如何防止图像在 Windows RT WebView 中变为 "draggable"

android - 按下设备后退按钮时出现 Flutter WebView 异常

java - 错误 :Execution failed for task ':app:compileDebugJavaWithJavac' . > java.lang.NullPointerException

android - 内容位于底部抽屉导航后面

android - 如何通过双击关闭 WebView?

android - 如何强制 Android Webview 在 DOM 更改时重新绘制?

android - 带有 Android Studio 的 Cordova webview(找不到文件 :///android_asserts/www/index. html)