将Rect变量转换为RectF变量的最佳方法是什么?我无法施展它。
RectF rect = (RectF) currentRect; //produces an error
答案 0 :(得分:17)
RectF rect = new RectF(currentRect);
答案 1 :(得分:1)
“不应在onDraw中完成”
// As class fields,
Rect rect = new Rect();
RectF rectF = new RectF();
...
onDraw(Canvas canvas) {
...
rectF.set(rect);
...
}