我在Android中使用WebView加載一些本地html,將圖像縮放到屏幕作爲背景。但是,當我開始加載WebView的活動時,我會在加載圖像之前獲得一個非常簡短的白屏。這不是一個大問題,但我想避免這個......我試圖將所有相關元素的背景設置爲黑色,但它仍然會發生......任何想法?使用html/css3和WebView將圖像縮放到屏幕上...在圖像加載之前獲取白色屏幕
這裏是我的html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>NerdRAGE</title>
<style>
* { margin: 0; padding: 0; }
html {
background: url(images/10_1.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body bgcolor="#000000">
</body>
</html>
這裏是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#000000" android:layout_width="fill_parent" android:layout_height="fill_parent">
<WebView
android:id="@+id/mapview"
android:background="#000000" android:scaleType="centerInside" android:layout_gravity="center_vertical|center_horizontal" android:clickable="false" android:fitsSystemWindows="true" android:scrollbars="none" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
</LinearLayout>
如果您將'body'和'html'設置爲'background-color:#000000;''會發生什麼? –
相同的結果...不幸的是,我不知道這個問題是在Android還是html/css結尾。 –
是否可以預加載圖像?這可能可以解決問題。 –