1

I was wondering is it possible to use drawText with an array so that it doesn't place each word onto of the other?

 for(int count =0; count<2; count++)
    {
        canvas.drawText(words[count], x, y, paint);

    }//for
4

1 回答 1

3

您需要更改xor y,因此:

for (int count = 0; count < words.length; count++) {
  canvas.drawText(words[count], x + 10 * count, y, paint);
}

这里,word[0] 将绘制在 (x, y) 处,而 word[1] 将绘制在 (x + 10, y) 处。但是,这不是很健壮。它假定所有单词都是 10 像素宽。

于 2013-06-14T21:37:31.320 回答