在Android中将RectF转换为Rect的最佳方式是什么? [英] What is the best way to convert from a RectF to a Rect in Android?

查看:466
本文介绍了在Android中将RectF转换为Rect的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从RectF转换为Android中的Rect。目前我有:

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?

推荐答案

啊哈 - 找到答案:

Ah ha -- found the answer:

rectF.round(rect);

-- or --

rectF.roundOut(rect);

这篇关于在Android中将RectF转换为Rect的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆