我正在 Android 中使用 WebView 来加载一些本地 html,将图像缩放到屏幕作为背景...但是,当我开始加载 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>
在这里找到这篇文章:
如何防止由于背景图像加载延迟而导致页面加载时出现白色“闪光”? https://stackoverflow.com/questions/7411541/how-to-prevent-the-white-flash-on-page-load-created-by-background-image-loadin
尝试为 html 元素设置背景颜色,并删除 body 元素上的 bgcolor="#000" 内联样式(应该避免这种情况。这是不好的做法)。
html {background: #[color] url('images/10_1.jpg') no-repeat center center fixed; }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)