标签: java casting
当我在我的代码中运行声纳时,我得到了以下ICAST:积分除法结果转换为double或float
float halfCanvasWidth = canvas.getWidth() / 2f;
canvas.getWidth()是整数如何正确转换
答案 0 :(得分:0)
如果你想将canvas.getWidth()转换为在java中浮动。试试这个:
canvas.getWidth()
float halfCanvasWidth = (float)canvas.getWidth() / 2f;