Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android问题中的HTML5画布_Android_Html_Canvas - Fatal编程技术网

android问题中的HTML5画布

android问题中的HTML5画布,android,html,canvas,Android,Html,Canvas,我想用画布制作一个渐变文本,我的电脑会正确地渲染代码,但是android会像普通渐变一样显示它,文本在里面。如果可能的话,我如何解决这个问题? 下面是javascript: function text() { var canvas = document.getElementById('header-text'); var ctx = canvas.getContext('2d'); var gradient = ctx.createLinearGradient(0, 0, 0, 29); gra

我想用画布制作一个渐变文本,我的电脑会正确地渲染代码,但是android会像普通渐变一样显示它,文本在里面。如果可能的话,我如何解决这个问题?
下面是javascript:

function text() {
var canvas = document.getElementById('header-text');
var ctx = canvas.getContext('2d');
var gradient = ctx.createLinearGradient(0, 0, 0, 29);
gradient.addColorStop(0, "#fcfcfc");
gradient.addColorStop(1, "#ccc");
ctx.font = "bold 29px helvetica, arial, sans-serif";
ctx.shadowColor = "#232323";
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.shadowBlur = 2;
ctx.fillStyle = gradient;
ctx.fillText("Company name", 0, 23);
}

很抱歉,这是一个错误

或者更确切地说,填充文本的渐变尚未在android浏览器上实现。如果你这样写:

var gradient = ctx.createLinearGradient(0, 0, 0, 29);
gradient.addColorStop(0, "#fcfcfc");
gradient.addColorStop(1, "#ccc");
ctx.fillStyle = 'red';
ctx.fillStyle = gradient; // replace the fillstyle with a gradient
ctx.fillText("Testing", 0, 23);
ctx.fillRect(0,0,20,20)
您将看到文本和矩形都具有渐变色

但是在android设备上,文本将是红色的,矩形将是渐变的


Chrome本身仍然不完全支持规范作者(他本人是谷歌的雇员)提出的所有画布渐变案例。我提交了一份关于它的bug报告。

很抱歉,这是一个bug

或者更确切地说,填充文本的渐变尚未在android浏览器上实现。如果你这样写:

var gradient = ctx.createLinearGradient(0, 0, 0, 29);
gradient.addColorStop(0, "#fcfcfc");
gradient.addColorStop(1, "#ccc");
ctx.fillStyle = 'red';
ctx.fillStyle = gradient; // replace the fillstyle with a gradient
ctx.fillText("Testing", 0, 23);
ctx.fillRect(0,0,20,20)
您将看到文本和矩形都具有渐变色

但是在android设备上,文本将是红色的,矩形将是渐变的


Chrome本身仍然不完全支持规范作者(他本人是谷歌的雇员)提出的所有画布渐变案例。我提交了一份关于它的错误报告。

你能添加有问题的代码吗?有不止一种方法可以在文本上生成渐变。你能添加有问题的代码吗?在文本上创建渐变的方法不止一种。仅添加渐变似乎对
arc
也不起作用。仅添加渐变似乎对
arc
也不起作用。