【问题标题】:WebView is loading wrong resolutionWebView 正在加载错误的分辨率
【发布时间】:2018-01-04 15:31:42
【问题描述】:

我正在开发一款适用于 Fire TV 的应用程序。我正在使用宽度为 1920 像素的电视。在应用程序中是一个全尺寸的 Web 视图(match_parent)。但如果我检查 WebView (window.screen.availWidth) 的分辨率,它只有 960 像素。

有人可以帮帮我吗?

【问题讨论】:

  • 您是否使用 ionic 或类似工具来创建应用 webview?
  • 不,我使用的是 Android Studio。
  • @Frederik Greve,我希望你的问题已经解决了。

标签: javascript android webview amazon-fire-tv


【解决方案1】:

Amazon Fire TV 平台将您的资源扩展到适当的电视输出。对于 1080p,屏幕尺寸为 1920x1080px,密度为 320dpi(“xhdpi”),输出分辨率为 960x540dp(“大”)。

https://developer.amazon.com/docs/fire-tv/design-and-user-experience-guidelines.html#screen-size-and-resolution

【讨论】:

    【解决方案2】:

    参考Display and Layout (Amazon Fire TV)

    当您的应用运行时,Fire TV 会从相应的文件夹加载您的资源。有关可用于 Amazon Fire TV 的资源配置的更多信息,请参阅下图显示和布局。
    android screen resolution

    【讨论】:

      【解决方案3】:

      您可以使用 html 'initial-scale' 来适应模板

      <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0">
      <script>
          /**
           * This script will set the 'initial-scale' value on the viewport metatag
           * The scale is used to fit the template on Kindle Fire mobile devices
           * This must be handled in the head of the document because the scale
           * is not affected once the page finishes loading
           */
          var vp = document.getElementById('viewport');
      
          var initialScale = Math.max(screen.width, screen.height) / 1920;
      
          vp.setAttribute('content', 'width=device-width, initial-scale=' + initialScale + ', maximum-scale=' + initialScale, +'minimum-scale=' + initialScale);
      
      </script>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-09-19
        • 2011-02-11
        • 1970-01-01
        • 2018-02-13
        • 1970-01-01
        • 2016-06-27
        • 2011-01-16
        相关资源
        最近更新 更多