What is the best way to convert from a RectF to a Rect in Android?

匿名 (未验证) 提交于 2019-12-03 02:24:01

问题:

I would like to convert from a RectF to a Rect in Android. Currently I have:

RectF rectF = new RectF(); rectF.set( ... some values ... );  ...  Rect rect = new Rect((int)rectF.left,                      (int)rectF.top,                      (int)rectF.right,                      (int)rectF.bottom)); 

Is there a better way?

回答1:

Ah ha -- found the answer:

rectF.round(rect);  -- or --  rectF.roundOut(rect); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!