gpt4 book ai didi

java - 将 drawText 与数组一起使用

转载 作者:行者123 更新时间:2023-11-29 05:42:01 24 4
gpt4 key购买 nike

我想知道是否可以将 drawText 与数组一起使用,这样它就不会将每个单词放在另一个单词之上?

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

}//for

最佳答案

您需要更改xy,因此:

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 像素。

关于java - 将 drawText 与数组一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17117478/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com