1
我有一個使用:hover
僞選擇器和cursor
屬性的具有幾種css懸停樣式的網頁。如果我在裝有鼠標的Android設備(例如Chromebook)上的嵌入式WebView中加載此網頁,則無法識別CSS懸停規則。光標始終相同,懸停突出顯示從不觸發。有什麼辦法來啓用這種行爲?懸停行爲在Android Webview中不起作用
的Java:
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>
的test.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>