Android WebView 输入类型="text" 光标未显示
Android WebView input type="text" cursor not showing
当我在 WebView 中单击输入文本字段 (input type="text")
时,该字段显示软键盘但未显示光标。
我可以输入文本,但没有光标...
当发生这种情况时,Logcat 说 "W/IInputConnectionWrapper﹕ showStatusIcon on inactive InputConnection" or "W/IInputConnectionWrapper﹕ getTextBeforeCursor on inactive InputConnection".
我尝试 override
我的 WebView 制作 onCheckIsTextEditor() return true;
,但没有任何效果。
请帮忙。
我通过将 focusable 设置为 WebView 的封闭视图解决了这个问题。
<?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>
这可能是因为光标颜色。您可以制作自己的自定义光标。
在可绘制文件夹中创建一个 XML 文件 color_cursor.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="2dp" />
<solid android:color="@color/cp_red" />
</shape>
并使用这个 属性
<item name="android:textCursorDrawable">@drawable/color_cursor</item>
当我在 WebView 中单击输入文本字段 (input type="text")
时,该字段显示软键盘但未显示光标。
我可以输入文本,但没有光标...
当发生这种情况时,Logcat 说 "W/IInputConnectionWrapper﹕ showStatusIcon on inactive InputConnection" or "W/IInputConnectionWrapper﹕ getTextBeforeCursor on inactive InputConnection".
我尝试 override
我的 WebView 制作 onCheckIsTextEditor() return true;
,但没有任何效果。
请帮忙。
我通过将 focusable 设置为 WebView 的封闭视图解决了这个问题。
<?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>
这可能是因为光标颜色。您可以制作自己的自定义光标。
在可绘制文件夹中创建一个 XML 文件 color_cursor.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="2dp" />
<solid android:color="@color/cp_red" />
</shape>
并使用这个 属性
<item name="android:textCursorDrawable">@drawable/color_cursor</item>