javascript - Android WebView Canvas 随机无法使用不同的宽度和高度
问题描述
对于以下测试,我使用了以下 HTML 片段,我使用了在线 HTML 编辑器和 Android-Emulator 中的 Android-WebView-Tester,屏幕为 9.7"。
此代码运行良好(Android-Webview-Tester 的图像:
var canvas = document.getElementById("myCanvas");
//canvas.setAttribute("height", "500");
ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>
此代码在浏览器上运行良好,但在 Android-Emulator 中运行良好(Android-Emulator 的图像不工作):
var canvas = document.getElementById("myCanvas");
//canvas.setAttribute("height", "500");
ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);
<canvas id="myCanvas" width="800" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>
这是一个已知问题吗?我错过了什么?我使用的是安卓 8.1
我对 Android-Chrome-Browser 没有任何问题,但我正在构建一个具有完全相同问题的 Cordova-App。Chrome-Webinspector 不会给出任何错误/警告。
解决方案
推荐阅读
- java - SoapUI - 以 JSON 格式发送登录详细信息
- javascript - 强制日期选择器反应小部件使用 UTC?
- c# - Unity 的 Webassembly 输出无法在 IOS 12.x 版本中启动
- ios - 我们如何在 iOS 中设置 HLS 流媒体的视频质量?
- python - 如何获取用户输入并使用 if else 函数提供输出
- javascript - 具有最小值和最大值的 Javascript 变量
- r - 如何从列表中动态多个过滤器
- cordova - 使用 phonegap 仅获取图像文件名和路径
- python - 如何在Django视图中乘以success_url?
- python - 计算调度问题中的雇佣天数