57

What is the difference between Rect and RectF in the Android SDK?

Kara
  • 6,115
  • 16
  • 50
  • 57
Iulius Curt
  • 4,984
  • 4
  • 31
  • 55

2 Answers2

55

Using Rect you define its edges using integers and using RectF they are defined as floats.

Looking at them more carefully I have spotted a few differences actually. I will only list what one implementation has more compared to the other one.

Rect

RectF

So apparently there are some differences.

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
  • Yep one is defined with int http://developer.android.com/reference/android/graphics/Rect.html the other with float http://developer.android.com/reference/android/graphics/RectF.html. a part form that I don't know of any difference which begs the question why create 2 separate classes for that ^^ – Jason Rogers Feb 06 '11 at 13:52
  • @JasonRogers I agree that it is somewhat funny. – Octavian Helm Feb 06 '11 at 13:59
  • I actually went to check the documentation to see if one didn't inherit the other with a bit of casting but not even that lol – Jason Rogers Feb 06 '11 at 14:01
  • @JasonRogers apparently there are some differences! I have listed them in my answer. – Octavian Helm Feb 06 '11 at 14:14
16

Rect is final, RectF can be extended

JayJay
  • 562
  • 12
  • 24