9
我想在Android中將RectF轉換爲Rect。目前我有:在Android中將RectF轉換爲Rect的最佳方式是什麼?
RectF rectF = new RectF();
rectF.set(... some values ...);
...
Rect rect = new Rect((int)rectF.left,
(int)rectF.top,
(int)rectF.right,
(int)rectF.bottom));
有沒有更好的方法?
最好的辦法是不要需要在兩者之間切換。如果你不得不這樣做,那就是。如果您需要更高的準確性,您可以對值進行舍入,而不是通過演員截取,但對於大多數情況不需要。 – 2013-05-08 19:59:56