【问题标题】:Displaying gifs downloaded from the web using windows phone 8.1使用 windows phone 8.1 显示从网上下载的 gif
【发布时间】:2015-01-14 19:48:20
【问题描述】:

一直在尝试在我的应用中显示 Gif,但我很难让事情正常工作。

似乎最快/最好/唯一的路线是使用 WebView。我在使用 WebView 时遇到的唯一问题是我需要拉伸 Gif 以适应屏幕,而没有证据(证据,如网页上的白色背景中所示)我从网络加载 Gif。

无论如何,是否有某种神奇的方式来显示 Gif 的描述?也许我们可以做一些 Javascript 或 HTML 技巧?

供参考的Gif:http://i.imgur.com/lfwQDq2.gif

(我确实尝试过使用 ImageTools,但由于某种原因我无法在我的应用程序上工作)

【问题讨论】:

    标签: c# xaml webview windows-phone-8.1 windows-8.1


    【解决方案1】:

    您不能将 WebView 的背景设置为透明 (AFAIK),并且 Image 元素不支持动画 GIF,因此您最好的选择可能是使用 WinForms 中的 PictureBox 控件,它支持动画 gif,您可以将背景设置为透明。
    可以在this answer 中找到有关如何执行此操作的示例

    我还刚刚在 GitHub 上找到了 this project(带有 nuget 包),它添加了几个 DependencyProperties,因此您可以使用 Image 元素,不过我还没有尝试过

    【讨论】:

      【解决方案2】:

      已修复!!

      我的解决方案:WP8: Download and save GIF to isolated storage

      结束了, ` var ImageURL = "http://i.imgur.com/BbL789a.gif";

              string backgroundColor = "<body bgcolor=\"#000000\">"; // enter different hex value for different background color 
      
              string imageHTML = "<html><head><meta name=\"viewport\" " +
                  "content=\"width=440\" id=\"viewport\" />" +
                  "</head>" + backgroundColor + "<IMG SRC=\"" +
                  ImageURL + "\"height=\"300\" width=\"300\"></body></html>";
      
              qwer.NavigateToString(imageHTML);`
      

      像冠军一样工作!现在我可以平静地死去。 :)

      【讨论】:

        猜你喜欢
        • 2015-11-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多