悬停行为在安卓网页视图中未生效



我有一个网页,它有几种 css 悬停样式,使用:hover伪选择器和通过cursor属性。 如果我在具有鼠标的Android设备(例如Chromebook(上的嵌入式WebView中加载此网页,则无法识别CSS悬停规则。 光标始终相同,悬停突出显示永远不会触发。 有没有办法启用此行为?

爪哇岛:

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate( Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
WebView webview = (WebView) findViewById( R.id.webview );
webview.loadUrl( "http://localserver/test.html" );
}
}

.XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="world.of.testapp.MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="368dp"
android:layout_height="495dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
</android.support.constraint.ConstraintLayout>

测试.html:

<html>
<head>
<style>
#a:hover {
color: red;
}
#b {
cursor: pointer;
}
</style>
</head>
<body>
<div id="a">HELLO</div>
<div id="b">WORLD</div>
</body>
</head>

看起来这是一个尚未在Android中实现的功能,并将很快发布:https://bugs.chromium.org/p/chromium/issues/detail?id=584424。

最新更新