【问题标题】:How to load gif image into webview in background?如何在后台将 gif 图像加载到 webview 中?
【发布时间】:2016-07-28 12:15:34
【问题描述】:

我有一个 web 视图,我在其中从资产加载 gif 图像。我在 viewpager 中有 10 个片段,每个片段在其顶部显示 gif 上都有 webview。我正在使用 loadDataWithBaseUrl 方法将 gif 加载到 webview 中。但它冻结了滚动。我需要在后台将 gif 图像加载到 webview 中。

【问题讨论】:

  • 尝试在页面内通过 JavaScript 加载,而不是将其硬编码为图像源。
  • 您是否只使用 WebView 以便显示 gif 图像?询问是因为可能有更好的选择。
  • 是的,我只使用 webview 。哪个解决方案比 webview 更好?

标签: android webview


【解决方案1】:

检查您的图像大小并尝试加载小于 30kb 的 gif。您应该知道您无法在后台线程中加载 UI。如果您在加载 gif 时仍有问题。尝试设计html页面

<!Doctype html>
<html>
<head>
<style>
html,body{
    padding:0 !important;
    margin:0 !important;
    overflow:hidden;
}
img{
width:100%;
height:100%;
}
</style>
</head>
<body style="background-image: url('static.gif')">

</body>
</html>

【讨论】:

    猜你喜欢
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    相关资源
    最近更新 更多